The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence starts with 0 and 1, and then each number is the sum of the two preceding ones.
You are given a function fibonacci(n: u32) -> u32
that takes a number n
and returns the n
-th number in the Fibonacci sequence.
Your job is to implement the function meeting the following requirements:
n
is 0, the function should return 0.n
is 1, the function should return 1.n
is greater than 1, the function should return the sum of the two preceding numbers.Here are some examples of how the behavior of the function should look like: