diff options
Diffstat (limited to 'examples/fib_rec.sloth')
| -rw-r--r-- | examples/fib_rec.sloth | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/fib_rec.sloth b/examples/fib_rec.sloth new file mode 100644 index 0000000..306bcdf --- /dev/null +++ b/examples/fib_rec.sloth @@ -0,0 +1,7 @@ +## Calculate a specific number in the fibonacci sequence +fn fib(n: i32) -> i32 { + match n { + 0 | 1 => n, + _ => fib(n - 1) + fib(n - 2), + } +} |
