Skip to content

Instantly share code, notes, and snippets.

@jonathan-irvin
Last active November 2, 2015 16:28
Show Gist options
  • Save jonathan-irvin/c738b48fce58d483595d to your computer and use it in GitHub Desktop.
Save jonathan-irvin/c738b48fce58d483595d to your computer and use it in GitHub Desktop.
Twin Primes
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