aboutsummaryrefslogtreecommitdiff
path: root/examples/fact.zc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/fact.zc')
-rw-r--r--examples/fact.zc7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/fact.zc b/examples/fact.zc
index 1790900..ae65453 100644
--- a/examples/fact.zc
+++ b/examples/fact.zc
@@ -1,4 +1,7 @@
+namespace;
+include rt;
+
fn fact(n) { if (n < 2) return 1; return n * fact(n - 1); }
// prints in binary, like the old asm example
-fn bin(n) { if (n > 1) bin(n >> 1); put_c('0' + (n & 1)); return 0; }
-fn main() { bin(fact(10)); put_c(10); put_n(fact(10)); put_c(10); return 0; }
+void bin(n) { if (n > 1) bin(n >> 1); rt.put_c('0' + (n & 1)); return; }
+void main() { bin(fact(10)); rt.put_c(10); rt.put_n(fact(10)); rt.put_c(10); return; }