diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-01-06 03:02:47 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-01-06 03:02:47 +0400 |
commit | 6030cdde103e889b17a3453b2a10526ee1f8ce1b (patch) | |
tree | cb4940126953df657a0ed48662b3b74e2b69580e | |
parent | eac82a359927bd544c7713dc9044cfec5d834172 (diff) |
Fibonacci example added
-rw-r--r-- | examples/fib.gorth | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/fib.gorth b/examples/fib.gorth new file mode 100644 index 0000000..d044d85 --- /dev/null +++ b/examples/fib.gorth @@ -0,0 +1,14 @@ +# Print out given number of elements in the Fibonacci sequence, 46 is the max value +define fib + var lim push lim + var a 1 push a + var b 1 push b + pull lim while dup 0 > do + pull a dump + pull b dup + pull a + + push b + push a + 1 - + done +end |