This page is not available on mobile. Please visit this page on a desktop.

Fibonacci

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:

If given n is 0, the function should return 0.

If given n is 1, the function should return 1.

If given n is greater than 1, the function should return the sum of the two preceding numbers.