sorry, not thinking, all prime numbers are odd except two.
and no prime number will have an integer sqrt, however, getting the sqrt of the number before hand will eliminate checking the sqrt multiple times. any program like this, is going to be run (most likely) using large numbers, since the small ones are readily available and the math is easy. 2, 3, 5, 7, 11.... so the amount of processes run cuts down signifigantly.
if you had say
Code:
sqrtnum = sqrt(iNum);
for (count = 0; count < sqrtnum; count++)
you would cut down on the execution of the sqrt. you could even make it faster, by checking to see if sqrtnum was an integer before the loop, so in the case of iNum being 100, the sqrt would be 10, thus skipping the loop. and making the function exponentially faster. in this case, it would skip running the loop 10 times, (or 4 times faster if you only check against prime numbers), and if you wanted to get really smart, you would do a check against 2 and 5 also before the loop, and only check numbers ending in 1, 3, 7,9 because if its even its composite as well as if it ends in 5.