What is the error in this code of java? package bakwas;
class bakwas {
public static void main(String[] args) {
int f1 = 0, f2 = 1;
System.out.print(f1);
System.out.print(f2);
do {
f2 = f2 f1;
System.out.print(f2);
} while (f2 < 10);
}
}
CodePudding user response:
f2 < 10
will always be true since f2
never increases in the loop. You need to give f1
a value greater than 0.
CodePudding user response:
you are doing f2(2) f1(0) so f2 is always 2 so you never increment anything