PRATEEK LOVES CANDY - Daily Coding Problems

PRATEEK LOVES CANDY - Daily Coding Problems



Prateek recently graduated from college. To celebrate, he went to a candy shop and bought all the candies. The total cost was a number upto which there are n prime numbers (starting from 2). Since Prateek wants to minimize his cost, he calls you to help him find the minimum amount that needs to be paid.

Input:
First line contains a single integer denoting the number of test cases T. Next T lines contains a single integer N, denoting the number of primes required.

Output:
Print the minimum cost that needs to be paid.

Sample Input:
2
5
1

Sample Output: 
11
2

Explanation:
In the first case there are 5 primes upto 11(2,3,5,7,11). Which is actually the minimum cost he needs to pay for 5 candies.



SOLUTION:
This problem seems to be purposely exaggerated. Never mind its easy.
You simply need to ask user how many candys he want to purchase as N. Now find out those many numbers of primes number and return the last prime number as the cost of ‘N’ candies.
Simple! Isn’t it?
Check the code:


Post a Comment

1 Comments