From 6030cdde103e889b17a3453b2a10526ee1f8ce1b Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Mon, 6 Jan 2025 03:02:47 +0400 Subject: Fibonacci example added --- examples/fib.gorth | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/fib.gorth 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 -- cgit v1.2.3