I need help with a program that will take an integer and output whether or not the number is prime or composite.
prime numbers
Collapse
X
-
Tags: None
-
Actually you only need to check 2, then the odd numbers from 3 to floor(sqrt(n)).
The reason is because if x, such that 1 < x < sqrt(number), is a factor, then (number/x) is a factor, and sqrt(number) <= number/x < number. Factors come in pairs, one will be less than or equal to sqrt(number), the other will be greater than or equal to sqrt(number).Comment
-
tel me how to write program on pallindrome?
tel me program which have output like
1
12
123
1234
12345Comment
Comment