RosettaCodeData/Task/Fibonacci-sequence/Idris/fibonacci-sequence-3.idris
2023-07-01 13:44:08 -04:00

5 lines
208 B
Text

fibIterative : Nat -> Nat
fibIterative n = fibIterative' n Z (S Z)
where fibIterative' : Nat -> Nat -> Nat -> Nat
fibIterative' Z a _ = a
fibIterative' (S n) a b = fibIterative' n b (a + b)