Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Given a number N, find the value of below equation for the given number.

 
Input:First line of input contains testcase T. For each testcase, there will be
a single line containing a number N as input.
 
Output:For each testcase, print the resultant of the equation.
Constraints:1<=T<=1001<=N<=105
Example:Input:41212199
Output:15597861328350
Explanation:For testcase 2, the resultant of the equation for N = 2 comes
out as 5.

The task is to convert decimal numbers(base 10) to the ternary


numbers(base 3).
Input:
First line of input contains testcase T. For each testcase there will be a
single line containing a decimal number N as input.
Output:
For each testcase, print the ternary(base 3) equivalent of the given decimal
number.
Constraints:
1<=T<=120
0<=N<=107
Example:
Input:
5
1
2
3
4
5
Output:
1
2
10
11
12
Explanation:
For testcase 1, we have input 1: The ternary equivalent of 1 is 1.
For testcase 5, we have input 5: The ternary equivalent of 5 is 12.

Given a number, find if it is Palindromic Prime or not.  A Palindromic Prime


is any number that is both a palindrome and a prime.
Input:
First line of input contains testcase T. For each testcase, there will be a
single line containing a number N as input.
Output:
For each testcase, print 1 if N is palindromic prime, else print 0.
Constraints:
1 <= T <= 200
0 <= N <= 107
Example:
Input:
4
1
11
121
99
Output:
0
1
0
0
Explanation:
For testcase 1, we have input 1: We know 1 is not a prime so we print 0.
For testcase 2, we have input 11: 11 is both a prime and palindrome so we
print 1.

Geek's high school has N lockers. On a particular day, Geeks decides to


play a game and open only those lockers that are multiple of M. Initially all
lockers are closed. Lockers are numbered from 1 to N. Find the number of
lockers that remain closed.
Input:
First line of input contains testcase T. For each testcase, there will be two
lines of input:
First line contains N, the number of lockers.
Second line contains M. Geeks will open lockers that are multiple of M.
Output:
For each testcase, print the number of lockers that remain closed.
Constraints:
1 <= T <= 100
1 <= N <= 107
0 <= M <= N
Example:
Input:
2
10
2
12
3
Output:
5
8
Explanation:
For testcase 1:
N = 10
M=2
We have 10 lockers and Geek opens lockers numbered 2,4,6,8,10. So, the
lockers that remain closed are 1,3,5,7,9. Which are a total of 5 lockers.

You might also like