Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fibonacciNumber(n)
- if n == 1 then
- return 1
- end
- if n == 2 then
- return 1
- end
- x = 2
- value_before = 1
- second_value_before = 0
- output_value = 0
- while (x <= n)
- output_value = value_before + second_value_before
- second_value_before = value_before
- value_before = output_value
- x = x + 1
- end
- return output_value
- end
Advertisement
Add Comment
Please, Sign In to add comment