Techfest and the Queue
Submissions: 352   Accuracy:

10.42%

  Difficulty: Medium   Marks: 4

The TerraTechnica (tech fest of NIT Delhi) is attracting lots of people. There is a long queue of people on the gate waiting to enter the event. Every person has a token which has a number written on it. All the numbers are sequential, means the token of the i th person contains the number i. But due to less availability of space, the fest manager decides to select some people and only allow them to enter the fest if they answer his question. He selects a person if and only if his/her token contains the number p, where p is between A and B (both inclusive). He allows them to enter the contest only if they answer his question which is.

"Print sum of the powers of primes , that occur in the prime factorization of the numbers written on all the tokens of the selected candidates".

As they know that you are very generous, they all ask you for help.

 

Constraints:
1 <= T <= 10
1 <= N <= 1012
1 <= A <= B <= N
B - A <= 105


Input:
The first line of the input contains an integer T, denoting the test cases. Then T test cases follow. The first and the only line of each test case contains the number N, A and B, as described above.


Output:
Output of each test case contains a single integer which represents the sum of the powers of primes , that occur in the prime factorization of the numbers written on all the token of the selected persons.

 

Example:
Input:

1
14
9 12

Output:
8

 

Explanation:
For p=9, prime factorization is : 32 
  So, sum of the powers of primes is: 2
For p=10, prime factorization is : 21x51 
  So, sum of the powers of primes is: 2
For p=11, prime factorization is : 111 
  So, sum of the powers of primes is: 1
For p=12, prime factorization is : 22x 31 
  So, sum of powers of primes is: 3
Therefore the total sum is 2+2+1+3=8.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Tanuj Yadav
Author: tanujyadav97


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.