ruju11235 / csp

Small programs using the JavaScript syntax. I'm just starting to learn :)
0 stars 1 forks source link

Nothing is better than fib for our first GitHub issue as a programming assignment! #2

Closed kedarmhaswade closed 1 month ago

kedarmhaswade commented 2 months ago

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.

  1. A recursive function.
  2. 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.

Ask clarifying questions here.

kedarmhaswade commented 1 month ago

Cool! Study both the functions to get a deeper understanding of Fib.