user3363245 - 1 month ago 13

Java Question

I cannot figure this question out no matter what i try, i may just be over thinking it, can i get a little help? Ive already tried a variety of different for loops and I can;t figure out how to get these values

`for(int a = 1; a<1000; a++)`

I want to make it so the it states a+b but i dont think thats possible

The following code is famous as Fibonacci, in which the Nth output is the sum of (N-

2)th and (N-1)th values. Write the for-expression to do the same task.

`int a=1, b=1;`

while (a < 10000 ){

System.out.print(a+" "+b+" ");

b+=a+=b;

}

Answer

Converting the while loop into a for loop, it would be:

```
for (int a=1, int b=1; a < 10000; b+=a+=b ){
System.out.print(a+" "+b+" ");
}
```