Your GitHub handle is very interesting! Yes, it has the first five numbers of the famous Fibonacci series. That prompted me to give you this programming assignment.
Write the definition of a function, fib, that takes a positive integer n as a parameter, and returns the nth Fibonacci number.
Make two versions of it.
A recursive function.
An iterative (using the usual loops) function.
Put each version in its own JavaScript file.
Apply your function to any positive integer in a program to test it out. For instance, console.log(fib(5) should print 5.
Document your code adequately. Test it out thoroughly.
Your GitHub handle is very interesting! Yes, it has the first five numbers of the famous Fibonacci series. That prompted me to give you this programming assignment.
Write the definition of a function, fib, that takes a positive integer n as a parameter, and returns the nth Fibonacci number.
Make two versions of it.
Put each version in its own JavaScript file.
Apply your function to any positive integer in a program to test it out. For instance,
console.log(fib(5)
should print5
.Document your code adequately. Test it out thoroughly.
Ask clarifying questions here.