aboutsummaryrefslogtreecommitdiff
path: root/tests/rec_fib.hgn
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rec_fib.hgn')
-rw-r--r--tests/rec_fib.hgn11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/rec_fib.hgn b/tests/rec_fib.hgn
new file mode 100644
index 0000000..9cbeed8
--- /dev/null
+++ b/tests/rec_fib.hgn
@@ -0,0 +1,11 @@
+main := proc() {
+ n := read_int(0)
+ f := fib(n)
+ print(f)
+ exit(0)
+}
+
+fib := proc(n) {
+ if n < 2 { return n }
+ return fib(n - 2) + fib(n - 1)
+}