Odd, Even and Prime No. from 1-150 in JAVA
public void main () { Log. e ("TAG", "main: Enter the number to check prime:"); checkPrime(); } public void checkPrime () { int i = 0; int num = 0; //Empty String String primeNumbers = ""; String evenNumbers = ""; String oddNumbers = ""; for (i = 1; i <= 150; i++) { int counter = 0; for (num = i; num >= 1; num--) { if (i % num == 0) { counter = counter + 1; } } if (counter == 2) { //Appended the Prime number to the String primeNumbers = primeNumbers + i + " "; } if (i % 2 == 0) { evenNumbers = evenNumbers + i + ", "; }else oddNumbers = oddNumbers + i + ", "; } System. out .println("Prime numbers from 1 to 150 are : " + primeNumbers ); System. out .println("Odd numbers from 1 to 150 are : ...