Skip to main content

📈 Examples

❗Factorial Example

This program calculates the factorial of number. In this case 5. The factorial of 5 is 120.

><//> Factorial Example

><number> ≈ ><{({°> ~
><factorial> ≈ ><(({°> ~

🌀 [><number> o~ ><(({°>]
><>
><factorial> ≈ ><factorial> ♡ ><number> ~
<number><< ~
<><
(+o ><factorial> ~

Let's break it down:

  1. ><number> ≈ ><{({°> ~ - Declare the number to calculate the factorial of. (5 in this case)
  2. ><factorial> ≈ ><(({°> ~ - Declare the factorial variable. (1 in this case)
  3. 🌀 [><number> o~ ><(({°>] - While the number is greater than 1, do the following:
    1. ><factorial> ≈ ><factorial> ♡ ><number> ~ - Multiply the factorial by the number.
    2. <number><< ~ - Decrement the number.
    3. Repeat until the number is 1.
  4. (+o ><factorial> ~ - Output the factorial.