0

Programming

To implement N-Fibonacci number

27th Mar 2018, 7:32 AM
Pragya Singh
Pragya Singh - avatar
1 Answer
+ 1
Using recursion could be the easiest Example in c#: int FibR(int n) { if(n ==0) return 0; if(n ==1) return 1; return FibR(n-2) +FibR(n-1); } If you want it to start counting at one just use one if if(n ==0 || n ==1) return 1; And they you can just write that method and give it a number or use a for loop if you want the whole sequence
28th Jun 2018, 8:05 PM
Megan Venter
Megan Venter - avatar