hello ;
here is a quastion . i understand it until the red senence , i do not know what dose it mean mathematically ?
Write a program that prompts the user to input a positive integer. It should then output indicating whether the number is a prime.
Note: an even number is a prime if it is 2. And an odd integer is prime if it is not divisible by any odd integer less than or equal to its square root.
Mathematically, any non-prime number will have a factor less than or equal to its square root. That means that if you have established that a number has no factor less than or equal to its square root, you have established that it is a prime number. Take 103 for example. The square root is about 10.15. Since factors must be integers, round down to 10. So to show that 103 is prime, you show that it has no factors less than or equal to 10. Further, you only have to test prime numbers. Hence, prove that 2, 3, 5, and 7 are not factors and you have proven that 103 is not prime. Thus you don't need to bother testing 4, 6, 8, and 10 since they are multiples of 2. You also don't need to test 9 since it's a multiple of 3.
Reputation Points: 2614
Solved Threads: 687
Posting Expert
Offline 5,375 posts
since Jan 2008