This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
divinity
wrote ...
2016/3/8
java code to find odd integer divisible by 3
divinity
2016/3/8
#
hi how do you write a java program that could print out all the odd integers divisible by 3.
danpost
2016/3/8
#
I am not going to write the whole program for you -- but I will show how the math works:
boolean oddMultipleOf3 = i%3 == 0 && i%2 == 1;
The first condition 'i%3 == 0' asks if the number ('i') is divisible by 3; the second one 'i%2 == 1' asks if the number is odd.
divinity
2016/3/9
#
thank very much danpost.
You need to login to post a reply.
X