From fff440ee980f909d0ff038f6b21ab1e1fbe2f07f Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 8 Jan 2022 23:14:07 +0100 Subject: [PATCH] Added trivial fibonacci implementation --- pieter/fibonacci.v | 9 +++++++++ pieter/main.v | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 pieter/fibonacci.v diff --git a/pieter/fibonacci.v b/pieter/fibonacci.v new file mode 100644 index 00000000..c76d44dd --- /dev/null +++ b/pieter/fibonacci.v @@ -0,0 +1,9 @@ +module fibonacci + +pub fn fib(i int) int { + if i <= 1 { + return i + } + + return fib(i - 1) + fib(i - 2) +} diff --git a/pieter/main.v b/pieter/main.v index 6b0e41be..3fef0e8e 100644 --- a/pieter/main.v +++ b/pieter/main.v @@ -1,3 +1,9 @@ +import fibonacci + fn main() { println('Hello, world!') + + for i in 1 .. 35 { + println('$i - ${fibonacci.fib(i)}') + } }