#C4937. Nth Prime Digit Slice
Nth Prime Digit Slice
Nth Prime Digit Slice
You are given a positive integer n
. Your task is to find the n-th prime number, say p, and then output a string composed of the first n characters of the string representation of p. In mathematical terms, if p_n is the n-th prime and s is the string representation of p_n, then you should output s[0:min(n, |s|)], i.e. the first min(n, |s|) characters of s.
Note: If n
is greater than the number of digits in p, then simply output the full string representation.
For example, if n = 5
, the 5th prime is 11 whose string representation is "11" (only 2 digits). Hence, the output is "11".
inputFormat
The input is provided via standard input and consists of a single integer n
on one line.
Constraints: 1 ≤ n ≤ 104 (or any reasonable bound as per contest limits).
outputFormat
Output the result string to standard output which contains the first min(n, |p|)
digits of the n-th prime number's string representation, where |p| denotes the number of digits in the prime.
1
2