fork(2) download
  1. #include<iostream>
  2.  
  3. using std :: cout;
  4. using std :: cin;
  5. using std :: endl;
  6.  
  7. int main()
  8. {
  9. long long int a = 0, bigPrime = 0, smallPrime = 2, prime = 0;
  10. cout << "Please enter a number...!" << endl;
  11. cin >> a;
  12.  
  13. for (long long int i = 2; i * i <= a; i++) {
  14. if (a % i == 0) {
  15. a /= i;
  16. i--; // this is to handle repeated factors
  17. }
  18. }
  19.  
  20. cout << "The biggest prime factor is = " << a << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 4512KB
stdin
600851475143
stdout
Please enter a number...!
The biggest prime factor is = 6857