#K55917. Identifying Prime Numbers in a List
Identifying Prime Numbers in a List
Identifying Prime Numbers in a List
In this problem, you are given a list of integers. Your task is to identify which numbers in the list are prime numbers and print their 1-indexed positions along with the number itself. A number ( n ) is considered prime if it satisfies the following conditions:
[ n > 1, \quad n \text{ is divisible only by } 1 \text{ and } n ]
You are required to read the input from standard input (stdin) and print the results to standard output (stdout). For each prime number found in the list, output a line in the following format:
Prime i: number
where ( i ) is the position of the number in the list (starting from 1). If a number is not prime, it should be ignored and no output should be produced for it.
Examples:
For the input list: [10, 3, 15, 23, 42, 31, 50], the output should be:
Prime 2: 3
Prime 4: 23
Prime 6: 31
For the input list: [1, 2, 3, 4, 5, 6, 7], the output should be:
Prime 2: 2
Prime 3: 3
Prime 5: 5
Prime 7: 7
inputFormat
The input begins with an integer ( n ) on the first line representing the number of elements in the list. The second line contains ( n ) space-separated integers.
outputFormat
For each prime number in the list, output a line formatted as "Prime i: number", where ( i ) is the 1-indexed position of that number in the list. If there are no prime numbers, do not output anything.## sample
7
10 3 15 23 42 31 50
Prime 2: 3
Prime 4: 23
Prime 6: 31
</p>