Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //What is the largest prime factor of the number 600851475143 ?
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool isPrime(unsigned long long int p)
- {
- for (unsigned long long int c = 2; c < sqrtl(p); c++)
- {
- if (p % c == 0) return false;
- }
- return true;
- }
- int main()
- {
- for (unsigned long long int i = 2; i < (600851475143 / 2); i++)
- if ((600851475143 % i == 0) && (isPrime(i) == true))
- cout << i << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement