hey friends..i'm trying to make a program to find the largest prime factor of a number of 12 digits.but i'm unable to figure out that what's the appropriate variable type for that.can u guys help me...
#include<stdio.h>
int main()
{
int c2;
unsigned long nbr=600851475143,lprime=2,prime,n=3;
do
{
for(c2=2;c2<n;c2++)
if(n%c2==0)
break;
else
{
prime=n;
if(c2==n-1)
{
if(nbr%prime==0)
{
lprime=prime;
//printf("%ld \n",prime);
}
//printf("%ld \n",prime);
break;
}
}
n++;
}while(n<nbr);
printf("%ld\n",lprime);
return 0;
}
this code gives following...
3(prime factor).c: In function ‘main’:
3(prime factor).c:5: warning: integer constant is too large for ‘long’ type
3(prime factor).c:5: warning: large integer implicitly truncated to unsigned type