- 1
How can I make loop that only prints even number ?
3 Respostas
+ 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