Last active
October 22, 2017 22:59
-
-
Save chaixdev/c0aeabd7d27aa3e479e840b3852a388d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package util; | |
import Printer.Printer; | |
public class PrimeFinder { | |
private Printer printer; | |
public PrimeFinder(Printer p){ | |
this.printer = p; | |
} | |
boolean isPrime(int n) { | |
for(int i=2;2*i<n;i++) { | |
if(n%i==0) | |
return false; | |
} | |
return true; | |
} | |
public void printValidPrimeTuples(int rangeMax) { | |
for(int a=0;a<rangeMax;a++) { | |
if(isPrime(a)) { | |
for(int i=0;i<3;i++) { | |
if(isPrime(a+i)); printer.print(String.format("(%d,%d)",a,a+i)); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment