+ 1
Can anyone help me solve this java question
Write a Java program start with an integer n, divide n by 2 if n is even or multiply by 3 and add 1 if n is odd, repeat the process until n = 1.
4 Answers
+ 1
https://code.sololearn.com/cT8RRstDGKM1/?ref=app
//My lame answer.
+ 1
I could've put for(<initializations>;<condition>;<increments>)
But none of it was required so I skipped it.
The semicolons are necessary and can't be skipped
This converts the loop yo an infinite one because of no increments and conditions
+ 1
The three parts of for loop: variable initialization, condition and variable update are optional. If the condition is absent, it is evaluated as true. The loop continues till something else in for loop block stops it. Since in your example for loop is empty, it is an infinite loop.
Stack overflow.
0
Mark V Zephurus what is for(;;) means?



