RosettaCodeData/Task/Fibonacci-sequence/Rhovas/fibonacci-sequence-1.rhovas
2023-07-01 13:44:08 -04:00

11 lines
266 B
Text

func fibonacci(num: Integer): Integer {
require num >= 0;
var previous = 1;
var current = 0;
for (val _ in range(1, num, :incl)) {
val next = current + previous;
previous = current;
current = next;
}
return current;
}