Given an array arr[] consisting of N integers in the range [0, M] and an integer M, the task is to count the number of… Read More

# Tag Archives: Modular Arithmetic

Given three positive integers, P, Q and N, the task is to find the GCD of (PN + QN) and (P – Q) under modulo… Read More

Given a positive integer N, the task is to find the value of (22 * X), where X is the binary representation of N. Since… Read More

Given an integer N, the task is to find the value of the expression ( N1 * (N – 1)2 * … * 1N) %… Read More

Given a positive integer N, the task is to find the count of all the numbers M such that when the number N is divided… Read More

Given two hexadecimal numbers N and K, the task is to find N modulo K. Examples: Input: N = 3E8, K = 13 Output: C Explanation: Decimal representation… Read More

Given a positive integer N, the task is to find the number of alphanumeric palindromic strings of length N. Since the count of such strings… Read More

Given three integers A, B and C, the task is to find the value of the expression Since the answer can be very large, print… Read More

Given an integer N and an integer FN which denotes the Nth term of the linear equation F(N) = (2 * F(N – 1)) %… Read More

Given an array arr[], the task is to count the number of unordered pairs (arr[i], arr[j]) from the given array such that (arr[i] * arr[j])… Read More

Given an array arr[] of length N and a positive integer M, the task is to find the Bitwise XOR of all the array elements… Read More

Given a prime number N, the task is to find the closest smaller number than N such that modulo multiplicative inverse of a number under… Read More

Given an array arr[] of size N and a prime number P, the task is to count the elements of the array such that modulo… Read More

Given 3 integers R, G, and B denoting the count of 3 colors Red, Green, and Blue respectively such that two different colors of the… Read More

Given a pair of coordinates (X1, Y1)(source) and (X2, Y2)(destination), the task is to check if it is possible to reach the destination form the… Read More