mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
8 lines
289 B
Python
8 lines
289 B
Python
fib 0 = 0
|
|
fib 1 = 1
|
|
# a type annotation is required for the recursive function
|
|
# NOTE: currently we must specify `n` as `Int` (not `Nat`), because Erg points out the possibility that `n-1` and `n-2` could be minus
|
|
fib(n: Int): Nat = fib(n-1) + fib(n-2)
|
|
|
|
assert fib(10) == 55
|
|
print! fib 10
|