1.

Given two integers L and R, write a program that finds the count of numbers having prime number of set bits in their binary representation in the range [L, R].

Example 1:

Input: L = 6, R = 10
Output: 4
Explanation: 6, 7, 9, 10 having
prime set bits between 6 and 10. 


Example 2:

Input: L = 10, R = 15
Output: 5
Explanation: 10, 11, 12, 13, 14 having
prime set bits between 10 and 15.


Your Task:  
You dont need to read input or print anything. Complete the function primeSetBits() which takes L and R as input parameter and returns the count of numbers having prime number of set bits in their binary representation.

Expected Time Complexity: O(nlog(n)sqrt(n))
Expected Auxiliary Space: O(1)

Constraints:
1 <= L <= R <=1000

2.

Given a number N, print all its unique prime factors and their powers in N.

N = 100
Factor Power
  2      2
  5      2

N = 35
Factor  Power
  5      1
  7      1

Input:
The first line of input contains an integer T denoting the number of test cases.The first line of each test case is N.

Output:
Print all prime factors and their powers separated by spaces.  The output should be printed in increasing order of prime factors.

Constraints:
1 ≤ T ≤ 200
2 ≤ N ≤ 10000

Example:

Input:
2
100
35
Output:
2 2 5 2
5 1 7 1
3.

Given a number N, the task is to find the largest prime factor of that number.
 

Example 1:

Input:
N = 5
Output:
5
Explanation:
5 has 1 prime factor
i.e 5 only.

Example 2:

Input:
N = 24
Output:
3
Explanation:
24 has 2 prime factors
3 and 2 in which 3 is
greater


Your Task:
You don't need to read input or print anything. Your task is to complete the function largestPrimeFactor() which takes an integer N as input parameters and returns an integer, largest prime factor of N.
 

Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(1)
 

Constraints:
1 <= N <= 105

4.

Given a sorted deck of cards numbered 1 to N.

1) We pick up 1 card and put it on the back of the deck.

2) Now, we pick up another card, it turns out to be card number 1, we put it outside the deck.

3) Now we pick up 2 cards and put it on the back of the deck.

4) Now, we pick up another card and it turns out to be card numbered 2, we put it outside the deck. ...

We perform this step until the last card.

If such an arrangement of decks is possible, output the arrangement, if it is not possible for a particular value of N then output -1.

Example 1:

Input:
N = 4
Output: 2 1 4 3
Explanation:
We initially have [2 1 4 3]
In Step1, we move the first card to the end.
Deck now is: [1 4 3 2]
In Step2, we get 1. Hence we remove it. Deck
now is: [4 3 2]
In Step3, we move the 2 front cards ony by one 
to the end  ([4 3 2] -> [3 2 4] -> [2 4 3]).
Deck now is: [2 4 3]
In Step4, we get 2. Hence we remove it. Deck
now is: [4 3]
In Step5, the following sequence follows:
[4 3] -> [3 4] -> [4 3] -> [3 4]. Deck now
is: [3 4]
In Step6, we get 3. Hence we remove it. Deck
now is: [4] Finally, we're left with a single
card and thus, we stop. 
 

Example 2:

Input:
N = 5
Output: 3 1 4 5 2


Your Task:  
You don't need to read input or print anything. Your task is to complete the function rotation() which takes the integer N as input parameters and returns If such arrangement of decks is possible, return the arrangement, if it is not possible for a particular value of n then return -1.



Expected Time Complexity: O(N^2)
Expected Auxiliary Space: O(1)

 

Constraints:
1 ≤ N ≤ 1000

5.

You are provided an unlimited collection of redgreen and blue balls. Now your task is to arrange N balls taken from this collection in a line in such a way that red balls appear first, followed by green balls and then blue balls. Given a value of you have to find the number of ways to do that.

Note:  In a particular arrangement a certain color of balls may be missing but the order must be strictly maintained with the available balls.
 

 

Example 1:

Input:
N = 1
Output:
3
Explanation:
You are allowed to take 1
ball only. So that one ball
can be red, green, or blue.
So the number of ways, in
this case is 3.

 

Example 2:

Input:
N = 2
Output:
6
Explanation:
You are allowed to take 2
balls. So you have six
alternative arrangements ie.
RG,GB,RB,RR,GG,BB.

 

 

Your Task:

You don't need to read input or print anything. Your task is to complete the function numberOfWays() which takes an integer N and returns the number of ways to do that.

 

Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

 

Constraints 
1<=N<=10^9