Factorial in Hack VM
Example for versions
Miller's Hack VM (JavaScript),
Miller's Hack VM (Python)
This example is pretty similar to Fibonacci numbers one, just with more characters to output. Note that data type is 32-bit integers, so 13! overflows: the output look like this:
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
!ERROR: integer overflow
28*0> 56*3+1> 84*2> 78*5+3> 25*4> 05> 16> 5<p1<P2<P3<P2<P6<p4<P 5<1+5> 5<6<*6> 0<1-0> 0<6? 67*c
Comments
]]>blog comments powered by Disqus
]]>