fork(2) download
  1. import java.math.BigInteger;
  2.  
  3. public class LargePrimeNumbers
  4. {
  5. public static void main(String[] args)
  6. {
  7. BigInteger n = new BigInteger(Long.MAX_VALUE + "");
  8. byte count = 0;
  9.  
  10. while(count < 5)
  11. {
  12. n = n.add(BigInteger.ONE);
  13.  
  14. if(isPrime(n))
  15. {
  16. System.out.println(n);
  17. ++count;
  18. }
  19. }
  20. }
  21.  
  22. public static boolean isPrime(BigInteger n)
  23. {
  24. if(n.remainder(new BigInteger("2")).equals(BigInteger.ZERO))
  25. {
  26. return false;
  27. }
  28.  
  29. BigInteger divisor = BigInteger.ONE;
  30.  
  31. while(true)
  32. {
  33. divisor = divisor.add(new BigInteger("2"));
  34.  
  35. if(n.remainder(divisor).equals(BigInteger.ZERO))
  36. {
  37. return false;
  38. }
  39. if(divisor.equals(n.divide(new BigInteger("2"))) || divisor.subtract(BigInteger.ONE).equals(n.divide(new BigInteger("2"))))
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. }
  46.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class LargePrimeNumbers is public, should be declared in a file named LargePrimeNumbers.java
public class LargePrimeNumbers
       ^
1 error
stdout
Standard output is empty