What is a Prime Number ?
If it is bigger than one and has no divisors other than 1 and itself.
==========================primenumbers.java=======================
public class primenumbers {
/**
* Calculating Prime Numbers
*
*/
public static void main(String[] args) {
int num1, num2, modulo = 0;
int maxPrimeNumber = 100;
for (num1 = 1; num1 < maxPrimeNumber; num1++) {
label:for (num2 = 2; num2 < num1; num2++) {
modulo = num1 % num2;
if (modulo == 0)
break label;
}
if (num1 == num2)
System.out.print(num1 + " : ");
}
}
}
====================================================
Output:
2 : 3 : 5 : 7 : 11 : 13 : 17 : 19 : 23 : 29 : 31 : 37 : 41 : 43 : 47 : 53 : 59 : 61 : 67 : 71 : 73 : 79 : 83 : 89 : 97 :
If it is bigger than one and has no divisors other than 1 and itself.
==========================primenumbers.java=======================
public class primenumbers {
/**
* Calculating Prime Numbers
*
*/
public static void main(String[] args) {
int num1, num2, modulo = 0;
int maxPrimeNumber = 100;
for (num1 = 1; num1 < maxPrimeNumber; num1++) {
label:for (num2 = 2; num2 < num1; num2++) {
modulo = num1 % num2;
if (modulo == 0)
break label;
}
if (num1 == num2)
System.out.print(num1 + " : ");
}
}
}
====================================================
Output:
2 : 3 : 5 : 7 : 11 : 13 : 17 : 19 : 23 : 29 : 31 : 37 : 41 : 43 : 47 : 53 : 59 : 61 : 67 : 71 : 73 : 79 : 83 : 89 : 97 :