diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-26 15:50:38 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-26 15:50:38 -0600 |
commit | 1851f5e76018ec1df3b55dce6cc9a64c9497bf7a (patch) | |
tree | 30f629f7b137a494d4202487f4e22df2d9456481 /base/Factorial.vapor | |
parent | 012298517078170762112abe2654dc69b2f146e1 (diff) |
Rearrange directory structure
Diffstat (limited to 'base/Factorial.vapor')
-rw-r--r-- | base/Factorial.vapor | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/base/Factorial.vapor b/base/Factorial.vapor new file mode 100644 index 0000000..28e1126 --- /dev/null +++ b/base/Factorial.vapor @@ -0,0 +1,30 @@ + +const vmt_Fac + :Fac.ComputeFac + + +func Main() + t.0 = HeapAllocZ(4) + [t.0] = :vmt_Fac + if t.0 goto :null1 + Error("null pointer") + null1: + t.1 = [t.0] + t.1 = [t.1+0] + t.2 = call t.1(t.0 10) + PrintIntS(t.2) + ret + +func Fac.ComputeFac(this num) + t.0 = LtS(num 1) + if0 t.0 goto :if1_else + num_aux = 1 + goto :if1_end + if1_else: + t.1 = [this] + t.1 = [t.1+0] + t.2 = Sub(num 1) + t.3 = call t.1(this t.2) + num_aux = MulS(num t.3) + if1_end: + ret num_aux |