i wanted to find largest prime factor of 600851475143, and i wrote a code that can calculate prime factor of 13195 or less numbers. but my code cannot calculate 600851475143 this numbers largest prime factor why is that ?
here is my code:
#include <stdio.h>
#include <math.h>
int main( ){
int n, a, b;
printf( "enter a number=> " );
scanf( "%d", &n );
for ( a = n; a >= 2; a-- ){
for ( b = 2; b <= a; b++ ){
if ( a % b == 0 ){break;}
else if ( b == a - 1 ){
if( n % a == 0 ){
printf("here is the largest prime number => %d\n", a);
return 0;
}
}
}
}
return 0;
}