hi,

A student approached me and asked why his prime checker wouldnt work. I took a look and it should work, imo, for all < 64 bit inputs.


Code:
int isitprime(unsigned long long in)
{
	unsigned long long c;
	unsigned long long max = sqrt(in);

	if(in <= 1 )
		return 0;

	if(in == 2)
		return 1;


	for(c=2; c<max; i++)
	{
		if(in%c == 0)
			return 0;
	}

	return 1;
}
checked for a bunch of primes i could think of 0,1,2,3,4,5,6,7 up to 18446744073709551557, which is supposed to be one of the largest 64 bit primes. Worked.

Does anyone see a mistake here?