fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. const long numm = 600851475143;
  6. long newnumm = numm;
  7. long largestFact = 0;
  8.  
  9. int counter = 2;
  10. while (counter * counter <= newnumm) {
  11. if (newnumm % counter == 0) {
  12. newnumm = newnumm / counter;
  13. largestFact = counter;
  14. } else {
  15. counter++;
  16. }
  17. }
  18. if (newnumm > largestFact) { // the remainder is a prime number
  19. largestFact = newnumm;
  20. }
  21. cout<<largestFact<<endl;
  22. // your code goes here
  23. return 0;
  24. }
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
6857