#K36582. Reach a Prime Card
Reach a Prime Card
Reach a Prime Card
You are given a card with an initial integer value. In one move, you can either increase the value by any integer k where 1 ≤ k ≤ 10, or double the value. Your goal is to find out whether it is possible to obtain a prime number on the card within at most 50 moves.
Formally, starting with an integer n, you are allowed to apply one of the following operations in each move:
- Add an integer k where 1 ≤ k ≤ 10, i.e. the new value becomes n + k.
- Double the number, i.e. the new value becomes 2n.
Determine if there exists a sequence of at most 50 moves that transforms the initial value into a prime number. The answer for each test case should be yes
if it is possible, and no
otherwise.
Note: It is known that, for most practical initial values, a prime number can be reached due to the density of primes. However, the search is limited to 50 moves.
Mathematically, you are to decide if there exists a sequence of moves such that for some 0 ≤ m ≤ 50 and operations op chosen from:
$$op(n) = n + k \quad (1 \le k \le 10) \quad \text{or} \quad op(n) = 2n, $$we have that the resulting number is prime.
inputFormat
The input is given via standard input (stdin) and has the following format:
T n1 n2 ... nT
Where T
denotes the number of test cases, and for each test case, a single integer n
is provided representing the initial value on the card.
outputFormat
For each test case, output a single line via standard output (stdout) containing either yes
if it is possible to obtain a prime number within at most 50 moves, or no
otherwise.
1
10
yes