Code:
int IsPrime(int a)
{
	int b;
	int c;
    if( (a div 2) == (a / 2))
    {
        c = 1;
    }
	for(b = 3;b < sqrt(a); b + 2)
	{ 
		if( (a div b) == (a / b))
		{
			c = 1;
		}
	}
	return c;
}

// Returns 0 if prime, 1 if not
This solves the problem, by checking for divisible by 2 first, then starting at 3, incrementing in 2's (all the odd numbers).