Question: GE Digital | OA | 2023 | Power of prime factors | GCD Pairs
3
Entering edit mode

Power of prime factors


You have a collection of books on a shelf and you want to determine how many of them have a certain level of complexity. Each book has a unique positive integer identifier. You have a list of K integers representing the
maximum sum of the powers of prime factors that each book can have to be considered "complex".


Count the number of books on the shelf that are considered "complex" based on the given criteria, and whose identifier is within the range I to r (inclusive)


Function description


Complete the spicyNumbers function. This function takes the following 4
parameters and returns the list of integer values:

  • l : Represents the leftmost value of the range
  • r. Represents the rightmost value of the range
  • g. Represents the size of query array k
  • k: Represents the array of integer values

 



 

GCD Pairs

Given two integers N and K.
Find out the of number of pairs (x, y) such that GCD(x , y) = K and 1 ≤ x, y  N where GCD(x,y) is the greatest common divisor of x and y.


Function description


Complete the KGCD function. This function takes the following 2 parameters and returns the count of required pairs:

  • N: Represents the number as described in the problem
  • K: Represents the number, such that GCD(x, y) = K


Input format for custom testing


Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.

 

  • The first line contains T, which represents the number of test cases.


For each test case:

  • The first line contains two space-separated integers N and K 

Constraints 

  • 1 ≤ T ≤ 5 * 105
  • 1≤ K ≤ N
  • 1≤ N ≤ 106

 

Sample Input              Sample Output

3                              1
1 1                            1
3 3                            3
4 2

 

 

Login before adding your answer.

Similar Posts
Loading Similar Posts