Given a integer 'num' you need to check whether it is a prime number or not.
for each test case there's only one query, so you do not need to build a prime table to optimized your solution just solve it in plain way.
In math, prime numbers are whole numbers greater than 1, that have only two factors – 1 and the number itself.
Prime numbers are divisible only by the number 1 or itself.
an Integer num
2<=num<=99999
if num is prime number then print '%d is a prime number' %num
else print '%d is not a prime number' %num
2
2 is a prime number
3
3 is a prime number
8
8 is not a prime number
when there's exist a factor 'f' then num/'f' is also it's factor, so you only need to check the factors until int(sqrt(num))
ID | User | Problem | Subject | Hit | Post Date |
沒有發現任何「解題報告」 |