Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int primesFound = 2; // skipping one and two
- int currentNumber = 3; // skip one and two
- System.out.println("Prime: 1"); //printing one and two
- System.out.println("Prime: 2");
- while (primesFound <= 30) {
- for (int i = 2; i < currentNumber / 2; i++) {
- if (currentNumber % i == 0) {
- System.out.println("Prime: " + currentNumber);
- primesFound++;
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment