#K68692. Prime Addresses
Prime Addresses
Prime Addresses
You are given a list of indices representing positions in the sequence of prime numbers. Your task is to output the corresponding prime numbers at those positions. The prime numbers are generated using the Sieve of Eratosthenes
algorithm. Note that the sequence of prime numbers starts with \(2\) as the first prime. For example, if the input indices are 1, 2, 10, then the output should be 2, 3, 29.
Formula: The \(n\)-th prime number is denoted by \(p_n\). Although there is no simple closed-form formula, the Sieve of Eratosthenes provides a practical method to compute primes up to a desired count.
inputFormat
The first line contains an integer (n), representing the number of indices. The second line contains (n) space-separated positive integers, each representing an index in the sequence of prime numbers (1-indexed).
outputFormat
Output (n) space-separated integers where each integer is the prime number corresponding to the given index from the input.## sample
3
1 2 10
2 3 29