1 # compute the factorial of 5, and return the result in the exit code 2 # 3 # To run: 4 # $ ./translate_mu apps/factorial.mu 5 # $ ./a.elf 6 # $ echo $? 7 # 120 8 # 9 # You can also run the automated test suite: 10 # $ ./a.elf test 11 # Expected output: 12 # ........ 13 # Every '.' indicates a passing test. Failing tests get a 'F'. 14 # There's only one test in this file, but you'll also see tests running from 15 # Mu's standard library. 16 # 17 # Compare apps/factorial4.subx 18 19 fn factorial n: int -> _/eax: int { 20 compare n, 1 21 # if (n <= 1) return 1 22 { 23 break-if-> 24 return 1 25 } 26 # n > 1; return n * factorial(n-1) 2