factorial.nbt 241 B

12345678910
  1. # Naive factorial implementation to showcase recursive
  2. # functions and conditionals.
  3. fn factorial(n) =
  4. if n < 1
  5. then 1
  6. else n × factorial(n - 1)
  7. # Compare result with the builtin factorial operator
  8. assert_eq(factorial(10), 10!)