aboutsummaryrefslogtreecommitdiff
path: root/tests/fibonacci.hgn
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2025-08-04 23:12:39 +0200
committerMathias Magnusson <mathias@magnusson.space>2025-08-04 23:12:39 +0200
commit392f0c4be0d4c034a4b161337f8f3c5fbf46358a (patch)
tree493cef6315b016e8ec7f9be051be7bb904e16add /tests/fibonacci.hgn
parent22f24043755ed320eff8a121aa1b80ede3b3a37f (diff)
downloadhuginn-392f0c4be0d4c034a4b161337f8f3c5fbf46358a.tar.gz
add a little test runnerHEADmain
Diffstat (limited to 'tests/fibonacci.hgn')
-rw-r--r--tests/fibonacci.hgn23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/fibonacci.hgn b/tests/fibonacci.hgn
new file mode 100644
index 0000000..f2ea776
--- /dev/null
+++ b/tests/fibonacci.hgn
@@ -0,0 +1,23 @@
+main := proc() {
+ n := read_int(0)
+ fib(n)
+ exit(0)
+}
+
+fib := proc(n) {
+ a := 0
+ b := 1
+ i := 0
+ while i < n {
+ c := a + b
+ a = b
+ b = c
+ i = i + 1
+ }
+ p(a)
+}
+
+p := proc(x) {
+ x2 := x
+ print(x2)
+}