Consecutive Primes
시간 제한15초메모리 제한1024 MB
각 Z에 대해 Z 이하이면서 연속한 두 소수의 곱인 값 중 가장 큰 것을 구한다.
문제
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 two consecutive prime numbers, such that it is the largest number that is smaller than or equal to . Given the value of , help John to determine the secret code.
Formally, let the order of prime numbers 2, 3, 5, 7, 11, ... be denoted by , , , , , ... and so on. Consider to be the product of two consecutive primes and . The secret code is the largest such that .
입력
The first line of the input gives the number of test cases, . lines follow.
Each line contains a single integer , representing the number provided by Ada as part of the hint.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the secret code - the largest number less than or equal to that is the product of two consecutive prime numbers.
제한
- .
힌트
For Sample Case #1, the secret code is 2021 because it is exactly the product of consecutive primes 43 and 47.
For Sample Case #2, the secret code is 1763 because the product of 41 and 43 is 1763 which is smaller than 2020, but the product of 43 and 47 exceeds the given value of 2020.