From ea62afb1dae6ded38b34689917ee520f6094edc2 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 29 Jan 2020 23:17:36 -0800 Subject: 5954 - 'factorial' working! --- html/apps/factorial.mu.html | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 html/apps/factorial.mu.html (limited to 'html/apps') diff --git a/html/apps/factorial.mu.html b/html/apps/factorial.mu.html new file mode 100644 index 00000000..f5e15b4e --- /dev/null +++ b/html/apps/factorial.mu.html @@ -0,0 +1,79 @@ + + + + +Mu - apps/factorial.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/master/apps/factorial.mu +
+ 1 fn main -> result/ebx: int {
+ 2   var tmp/eax: int <- factorial 5
+ 3   result <- copy tmp
+ 4 }
+ 5 
+ 6 fn factorial n: int -> result/eax: int {
+ 7   compare n 1
+ 8   {
+ 9     break-if->
+10     result <- copy 1
+11   }
+12   {
+13     break-if-<=
+14     var tmp/ecx: int <- copy n
+15     tmp <- decrement
+16     result <- factorial tmp
+17     result <- multiply n
+18   }
+19 }
+
+ + + -- cgit 1.4.1-2-gfad0