|
| 05 Mar 2015 05:59 PM |
Hey OT, time to learn some stuff and test your brain power.
A recursive function is a code function that calls itself to find an answer. For example : 6 factorial is equal to 6 * 5 * 4 * 3 * 2 * 1. This can recursively be written as factorial(6) = 6 * factorial(5) where, function factorial(int i) { if (i <= 1) return 1; else return factorial( i - 1 ); }
For today's challenge, write a recursive function to find the number at a provided sequence in the Fibonacci sequence. The sequence is as follows: 1 1 2 3 5 8 13 21 34 55 89 etc.
So, if I asked for fibonacci(6), your function should return the value 8. |
|
|
| Report Abuse |
|
|
GyroPulse
|
  |
| Joined: 05 Jun 2011 |
| Total Posts: 4886 |
|
| |
|
| |
|
|
| 05 Mar 2015 06:02 PM |
If you need help, you can Google "recursion"
and, amusingly enough, it will ask you if you meant "recursion" |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Mar 2015 06:03 PM |
but your username is "iMightBeLying" how do we trust you? |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:05 PM |
| You don't have to trust me to write code. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:06 PM |
| but what if this is all a troll, good sir? |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:08 PM |
| I trust in your internet detective abilities to sniff out the truth from the lies. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:09 PM |
| well what if i joined the internet a couple days ago? |
|
|
| Report Abuse |
|
|
GyroPulse
|
  |
| Joined: 05 Jun 2011 |
| Total Posts: 4886 |
|
|
| 05 Mar 2015 06:09 PM |
| oooh this kid is getting roasted |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Mar 2015 06:10 PM |
| Quit trying to get off topic. Have you guys and gals even noticed the pattern yet? |
|
|
| Report Abuse |
|
|
GammaGeek
|
  |
| Joined: 10 Aug 2014 |
| Total Posts: 11182 |
|
|
| 05 Mar 2015 06:11 PM |
Do I get your lunch money if I do this
"The problem with internet quotes is that you cannot always depend on their accuracy." - Abraham Lincoln, 2013. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:11 PM |
well, i am just gonna back out of this before i get banned also, you literally just told me to quit getting off topic IN OFF TOPIC |
|
|
| Report Abuse |
|
|
GyroPulse
|
  |
| Joined: 05 Jun 2011 |
| Total Posts: 4886 |
|
|
| 05 Mar 2015 06:11 PM |
| ah i see.. the numbers must be my hourly income... nice job figuring that out. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:12 PM |
"Quit trying to get off topic."
Are you sure you meant to post this here? |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:12 PM |
Marvelous point. How does cat? What am food? When is spaghetti?
Anyways, I'm not going to ban you, but let's get back to math. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:12 PM |
don't worry moderator bro im working hard on this code
"The Sauza so malo...", and then she said "You need to grow up." |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Mar 2015 06:13 PM |
yes thank you moderator! you are pretty cool y'know |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:13 PM |
is this a joke why would u post this in ot, u know we cant haddle this!!! |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Mar 2015 06:14 PM |
Alright, I think this is right or at least close:
function fibonacci(int i) { if(i <= 1) return 1; else return fibonacci(n - 1) + fibonacci(n - 2)
"The Sauza so malo...", and then she said "You need to grow up." |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2015 06:14 PM |
@classicShrek I believe you guys are smarter than you think you are. |
|
|
| Report Abuse |
|
|