Daily kata practise
Today I will try to work on the things that I mentioned at the end of the last session.
Time: 10 mins
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
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.
I'm thinking about C for next time 👀