#P16843. [GKS 2021 #B] Consecutive Primes

[GKS 2021 #B] Consecutive Primes

Problem Description

Ada has bought a secret present for her friend John. In order to open the present, Ada wants John to crack a secret code. She decides to give him a hint to make things simple for him. She tells him that the secret code is a number that can be formed by taking the product of 22 consecutive prime numbers, such that it is the largest number that is smaller than or equal to ZZ. Given the value of ZZ, help John to determine the secret code.

Formally, let the order of prime numbers 2,3,5,7,11,2, 3, 5, 7, 11, \ldots be denoted by p1,p2,p3,p4,p5,p_1, p_2, p_3, p_4, p_5, \ldots and so on. Consider RiR_i to be the product of 22 consecutive primes pip_i and pi+1p_{i+1}. The secret code is the largest RjR_j such that RjZR_j \le Z.

Input Format

The first line of the input gives the number of test cases, TT. TT lines follow.

Each line contains a single integer ZZ, representing the number provided by Ada as part of the hint.

Output Format

For each test case, output 11 line containing Case #x: followed by yy, where xx is the test case number (starting from 11) and yy is the secret code - the largest number less than or equal to ZZ that is the product of 22 consecutive prime numbers.

2
2021
2020
Case #1: 2021
Case #2: 1763

Hint

For Sample Case #11, the secret code is 20212021 because it is exactly the product of consecutive primes 4343 and 4747.

For Sample Case #22, the secret code is 17631763 because the product of 4141 and 4343 is 17631763 which is smaller than 20202020, but the product of 4343 and 4747 exceeds the given value of 20202020.

Limits

1T1001 \le T \le 100.

Test Set 11

6Z20216 \le Z \le 2021.

Test Set 22

6Z1096 \le Z \le 10^9.

Test Set 33

6Z10186 \le Z \le 10^{18}.