terminate - My C code doesn't output anything, or end running -
i'm trying answer question: the prime factors of 13195 5, 7, 13 , 29. what largest prime factor of number 600851475143 ? here code: #include <stdio.h> int isprime(long long num) { (long long k = 1; k < num; k++) { if (num%k == 0) return 0; } return 1; } long long num = 600851475143; int main(void) { long long prime_factor = 0; (long long j = 2; j < num; j++) { if (num % j == 0 && isprime(j) == 1) prime_factor = j; } printf("%lli\n", prime_factor); } but reason doesn't print anything, or end. causing this? that's terribly inefficient way of finding prime factors of number. to find prime factors, should: create static list of primes less or equal (number / 2). iterate on each element in list of primes , see if each 1 can evenly divide number. divide original number prime, , check last number again...