Quick Question, the code included is returning a Fibonacci value but it's the wrong value, it's off by 2, e.g. the user enters ten and 89 is returned, instead of 34. Basically I just want to return the Fibonacci value of the value entered by the user ?
Can anyone spot the problem ? Thanks
var Newmodel = new FibonacciModel();
int a = 0;
int b = 1;
for (int i = 0; i < model.InputFromUser; i++)
{
model.FibonacciValue = a + b;
a = b;
b = model.FibonacciValue;
}
Newmodel.InputFromUser = model.InputFromUser;
Newmodel.FibonacciValue = model.FibonacciValue;
return View(Newmodel);