I\'ve been interested in the problem of finding a better prime number recognizer for years. I realize this is a huge area of academic research and study - my interest in this i
A simple improvement would be to change the for loop to break out when it finds a factor:
for (i = 2; i <= ceiling && !factorFound; i++) { if (input % i == 0) { factorFound = 1;
Another possibility would be to increment the counter by 2 (after checking 2 itself).