#K9431. Prime and Composite Classification
Prime and Composite Classification
Prime and Composite Classification
You are given a sequence of integer numbers from standard input. Process the numbers sequentially until you encounter the number -1
. For each number (before -1
), classify it according to the following rules:
- If the number is less than or equal to 1, output
neither
. - If the number is greater than 1 and is a prime, output
prime number
. - If the number is greater than 1 and not a prime, output
composite number
.
A prime number is defined as an integer \( n > 1 \) such that it has no positive divisors other than \( 1 \) and \( n \). The classification must be printed one per line to standard output.
Note that the input will always include a -1
to signify the termination of input. Any numbers appearing after -1
should be ignored.
inputFormat
The input is read from standard input and consists of a series of integer numbers separated by spaces or newlines. The sequence is terminated by the integer -1
, which should not be processed.
outputFormat
For each number processed (before the termination value -1
), output its classification as either prime number
, composite number
, or neither
. Each classification should be printed on its own line. No extra output should be produced.
5 10 1 23 0 18 -1
prime number
composite number
neither
prime number
neither
composite number
</p>