Məsələlər
L. Lucky Primes
L. Lucky Primes
Stefan calls an positive integer p lucky prime, if p and number p[1]
, obtained by reversing its decimal notation, i.e. reading all digits from end to beginning, are distinct primes.
Remind that positive integer is prime, if it has no positive integer divisors except for 1 and itself.
Given K , find K -th lucky prime.
####InputFirst line of the input contains one integer K (1 ≤ K ≤ 1000).
####OutputIf K -th lucky prime is not greater than 10^6
, print it. Otherwise print - 1.
Nümunə
Giriş verilənləri #1
1
Çıxış verilənləri #1
13