--Originally published at Loading…
Hi! I know that I should have posted this since Friday, but I couldn’t post it before.
This quiz was a kind of… different, at the begging I didn’t understand very well it said:
Write a function that calculates returns the “nth” Fibonacci number where we define a function over the Fibonacci numbers mapping the naturals (starting with zero) to the Fibonacci series. So fibonacci(0) returns 0, fibonacci(1) returns 1, fibonacci(2) returns 1 and so on. Note that we are using the modern definition where the sequence starts with zero.
I know the Fibonacci series since the elementary school and I think it is absolutely AMAZING! But I didn’t know there was a formula to calculate any number in the series and that was the interesting part about this quiz, Ken gave us a very clearly explanation about it.
This is my code:
While I was searching about the Fibonacci number and how my others classmates did this quiz, I found this page and I copied and pasted it one of the codes to print the series int he program, I know it’s wrong but it gave me a little laziness to do it by myself. It easier made the program with a function. At the begging I don’t understand how I supposed to count the numbers in the series but then Ken explained me that I have to star with the 0 like 0, 1, 2, 3… and this is how it works:
P.S: It supposed that between the 0 and the 1 there should be a space.