blob: ee928e869b32e3df7fc9813193e1e2f4cf5bfa6f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
(factorial
((default-scope scope-address) <- new (scope literal) (30 literal))
((n integer) <- arg)
{ begin
; if n=0 return 1
((zero? boolean) <- eq (n integer) (0 literal))
(break-unless (zero? boolean))
(reply (1 literal))
}
; return n*factorial(n-1)
((x integer) <- sub (n integer) (1 literal))
((subresult integer) <- factorial (x integer))
((result integer) <- mul (subresult integer) (n integer))
(reply (result integer)))
(main
((1 integer) <- factorial (5 literal)))
|