Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PrimeNumbers {
- public static void main(String[] args) {
- int top = 100;
- for (int i=2;i<top;i++){
- if(checkSimple(i))
- System.out.println(i);
- }
- }
- public static boolean checkSimple(int i){
- if (i<=1)
- return false;
- else if (i <=3)
- return true;
- else if ((i%2==0) | (i %3 ==0))
- return false;
- int n = 5;
- while (n*n <=i){
- if (i % n ==0 | i % (n+2) == 0)
- return false;
- n=n+6;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment