Last active
November 2, 2015 16:28
-
-
Save jonathan-irvin/c738b48fce58d483595d to your computer and use it in GitHub Desktop.
Twin Primes
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 twinPrimes { | |
public static void main(String[] args) { | |
for(int i=2;i<1000;i++){ | |
if( (isPrime(i)) && (isPrime(i+2)) ){ | |
System.out.println("(" +i+ "," +(i+2)+ ")"); | |
} | |
} | |
} | |
public static boolean isPrime(int number) { | |
for (int divisor =2; divisor < number; divisor++){ | |
if (number % divisor == 0){ | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment