Hi I am working on a program that check whether it is a prime number or not.Please helpe test my program whether it runs ok or not. If any good advice, please post your words below my programming. thanks guys.
Seems ok. (can't compile it right now). One thing you could improve is that to find a factor (or to check if it is prime) you don't need to check all numbers from 1 to n. You only need to check from 1 to sqrt(n). So change your for loops to i*i <= number. In your factor function you needn't start from 1 because all integers can be divided by 1 without a remainder. Also, if you do the i*i thing you will have to say that a factor of n is n (as a separate case). Lastly, whats is CinReader? Why do you need it? Is it something you wrote yourself?
Thanks ur advice. u r right. if square, the program can save time...
CinReader is a class My friend write for output. it works well when using output with some conditions. You can change to cin cout.. it still works.