fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) {
  11. long sum = 2;
  12. long isPrime;
  13. for(long x = 3; x < 2000000; x+=2){//x is the number we check for if it is a prime
  14. isPrime = 0;
  15. long y = 3;
  16. while(isPrime == 0) {
  17. if(x%y==0){
  18. isPrime = 1;
  19. }
  20. if(y*y > x) {
  21. isPrime = 1;
  22. sum+=x;
  23. }
  24. y += 2;
  25. }
  26. }
  27. System.out.println(sum);
  28. }
  29. }
Success #stdin #stdout 3.83s 320576KB
stdin
Standard input is empty
stdout
142913828922