Sam
BAN USER
Comments (3)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
-1
of 1 vote
If I'm understanding this correctly, this should be fairly straightforward. Here's an iterative solution (in C#):
public static void PrintFibonacci(int start, int end)
{
int previousFib = 0, currentFib = start;
while (currentFib < end)
{
Console.WriteLine(currentFib);
int newFib = previousFib + currentFib;
previousFib = currentFib;
currentFib = newFib;
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
This can be solved using recursion fairly easily.
Here's a solution in C#
- Sam October 15, 2013