/katas-daily

Daily kata practise

Primary LanguageTypeScript

katas-daily

Daily kata practise

7/10/2021 8:50am

Today I will try to work on the things that I mentioned at the end of the last session.

Task

Time: 10 mins

Nth Fibonacci

From AgileTechPraxis/katalog.

Write a function that generates the Fibonacci number for the Nth position implementing the method with signature:

int Fibonacci(int position)

First Fibonacci numbers in sequence:

Position 1 2 3 4 5 6 7 8 9
Fibonacci 1 1 2 3 5 8 13 21 34

Wrap up

I couldn't think of another solution to keep the result of fibonacci sequence 1 or 2 at one. Using the if is the simplest method I could think of, but I am still wondering if there's a way to ensure it returns one for these with a mathematical formula instead of a conditional expression.

Things for next time

I'm thinking about C for next time 👀