BETA

Submissions: 571 Accuracy: 17.86%

Prime Palindrome Sum

Given is a range of integers [a , b]  . You have to find the sum of all the numbers in the range  [ a , b] that are prime as well as palindrome .

Input:
The first line of input contains an integer denoting the number of test cases . Next line of input contains the range for which one has to find the sum .

Output:
For each test case , the output is in a new line containg the sum of all the numbers those are prime and palindrome in the input range .

Constraints:
0 < = a < = 100000
0 < = b < = 100000
b > a
t (testcases < = 200)

Example:
Input:

2
1 10
101 200
Output:
17
755
Explanation :
Between 1 and 10 ,
prime numbers = 2 , 3 , 5 , 7  and out of these palindromes = 2 , 3 ,  5 , 7
So , sum = 17 .
Between 101 and 200
prime numbers =  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199  and out of           these palindromes = 101 , 131 , 151 , 181 , 191
So , sum = 755

Example 2 :
Sample Input:
2
1 100
10 200
Sample Output:
28
766

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

Contributor: Diksha Singhal

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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