fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.math.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. long startTime = System.nanoTime();
  11. int p = 8624;
  12. BigInteger Two = BigInteger.valueOf(2L);
  13.  
  14. M = M.setBit(p);
  15. M = M.subtract(BigInteger.ONE); // M = 2^p - 1;
  16.  
  17. BigInteger S = BigInteger.valueOf(4L);
  18.  
  19. while(p>2) {
  20. S = S.pow(2).subtract(Two).mod(M);
  21. p--;
  22. }
  23. // System.out.println(S);
  24. long endTime = System.nanoTime();
  25. System.out.println("Took "+(endTime - startTime) + " ns");
  26.  
  27. }
  28. }
Success #stdin #stdout 2.27s 2184192KB
stdin
Standard input is empty
stdout
Took 2239053066 ns