What is the code to write in int Fibonacci (int n) without using "if" like they did here Java recursive Fibonacci sequence ? I tried to write this but it is wrong : Because in this program the list will be 1 1 2 3 5 8 and not 0 1 1 2 3 5 8
Here is the program I tried to write:
public class Fibonacci
{
public static void main(String[] args)
{
int f = 0;
int g = 1;
for(int i = 1; i <= 10; i++)
{
f = f + g;
g = f - g;
System.out.print(f + " ");
}
System.out.println();
}
}