- 1
How can I make loop that only prints even number ?
3 odpowiedzi
+ 1
An even number is a number thay doesn’t leave any remainder after dividing by 2.
An operator that gives you a remainder from division is modulo operator ‚%’
Example: 4%2 will equal zero, because 4 is divisible by 2 without any remainder.
5%2 equals 1, because you can put two ‚2’ inside the ‚5’, but there is still a ‚1’ left ( 2+2+1 )
Use it as an if statement inside a loop and you’re good to go ( run the Java course if you haven’t already ) Best of luck
+ 1
Martin Taylor You’re right, thanks