-
-
Save SocraticPhoenix/373bde3302f801f8bac67ab8895b5a2b to your computer and use it in GitHub Desktop.
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
import java.math.BigInteger; | |
public class Test { | |
public static void main(String[] args) { | |
BigInteger integer = new BigInteger("15465347049748408180402050551405372385300458901874153987195606642192077081674726470827949979631079014102900173229117045997489671500506945449681040725068819"); | |
BigInteger two = new BigInteger("2"); | |
for (BigInteger i = new BigInteger("2"); i.compareTo(integer) < 0; i = i.add(two)) { | |
if(isPrime(i)) { | |
if (integer.remainder(i).compareTo(BigInteger.ZERO) == 0) { | |
System.out.println(i); | |
} | |
} | |
} | |
} | |
public static boolean isPrime(BigInteger integer) { | |
if(integer.remainder(new BigInteger("2")).compareTo(BigInteger.ZERO) == 0 || integer.remainder(new BigInteger("3")).compareTo(BigInteger.ZERO) == 0) { | |
return false; | |
} | |
BigInteger siz = new BigInteger("6"); | |
for(BigInteger i = new BigInteger("6"); i.pow(2).compareTo(integer) < 0; i = i.add(siz)) { | |
if(integer.remainder(i.subtract(BigInteger.ONE)).compareTo(BigInteger.ZERO) == 0 || | |
integer.remainder(i.add(BigInteger.ONE)).compareTo(BigInteger.ZERO) == 0) { | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment