diff options
| author | Cody <cody@codyq.dev> | 2023-02-27 07:21:50 -0600 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-02-27 07:21:50 -0600 |
| commit | ebfd74ddf0ef6372624ea171e06f8460d0e1351b (patch) | |
| tree | d59df0e9600a6f2b86b57949048cf990a3e102ae /examples/fib_rec.sloth | |
| parent | a653a6602fe5ae5eb4739755db7b34bc92ecdadf (diff) | |
| download | sloth-ebfd74ddf0ef6372624ea171e06f8460d0e1351b.tar.gz | |
pain
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), + } +} |
