Last active
August 29, 2015 14:19
-
-
Save jonathan-irvin/22f8339849d0e5b44b6a to your computer and use it in GitHub Desktop.
Bruteforce Prime finder in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BrutePrime { | |
public static void main(String[] args) { | |
final int END_VALUE = 1000000; | |
for(int number=2;number<END_VALUE;number++){ | |
boolean isPrime = true; | |
//check divisors to see isPrime | |
for(int divisor=2;divisor<number;divisor++){ | |
if(number % divisor ==0){ | |
isPrime = false; | |
break; | |
} | |
} | |
//isPrime, output | |
if(isPrime == true){ | |
System.out.println(number); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment