fork download
  1. # require 'Math'
  2. class Prime
  3. def calc
  4. i = 1
  5. j = 1
  6. max = 1
  7. limit = 600851475143
  8. for i in 2..limit
  9. prime = true
  10. for j in 2..Math.sqrt(i)
  11. if i%j==0
  12. prime = false
  13. break
  14. end
  15. end
  16. if prime == true
  17. if limit % i == 0
  18. if i>max
  19. max = i
  20. end
  21. end
  22. end
  23. end
  24. return max
  25. end
  26. end
  27.  
  28. num = Prime.new
  29. print num.calc
Time limit exceeded #stdin #stdout 5s 29720KB
stdin
Standard input is empty
stdout
Standard output is empty