/* The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? */ #include char is_prime(unsigned long long int n) { for (unsigned long long int i = 2; i < n; i++) { if (n % i == 0) { return 0; } } return 1; } int main() { unsigned long long int c = 600851475143; for (unsigned long long int i = c / 2; i--; i >= 0) { printf("%llu\n", i); if (is_prime(i)) { printf("%llu\n", i); break; } } }