## Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B

Given three positive integers N, A and B. The task is to count the numbers of length N containing only digits A and B and… Read More »

## Count of pairs of (i, j) such that ((n % i) % j) % n is maximized

Given an integer n, the task is to count the number of pairs (i, j) such that ((n % i) % j) % n is… Read More »

## Find minimum x such that (x % k) * (x / k) == n

Given two positive integers n and k. Find minimum positive integer x such that the (x % k) * (x / k) == n, where… Read More »

## LCM of N numbers modulo M

Given an array arr[] of integers, the task is to find the LCM of all the elements of the array modulo M where M =… Read More »

## Expressing a fraction as a natural number under modulo ‘m’

Given two integers A and B where A is not divisible by B, the task is to express A / B as a natural number… Read More »

## Find the number of primitive roots modulo prime

Given a prime . The task is to count all the primitive roots of . A primitive root is an integer x (1 <= x… Read More »

## Sort elements of array whose modulo with K yields P

Given an array of integers and a number K. The task is to sort only those elements of the array which yields remainder P upon… Read More »

## GCD of a number raised to some power and another number

Given three numbers a, b, n. Find GCD(an, b). Examples: Input : a = 2, b = 3, n = 3 Output : 1 2^3… Read More »

## Smallest odd digits number not less than N

Given a number N, the task is to find the smallest number not less than N, which has all digits odd. Examples: Input: N =… Read More »

## Split the number into N parts such that difference between the smallest and the largest part is minimum

Given two integers ‘X’ and ‘N’, the task is to split the integer ‘X’ into exactly ‘N’ parts such that: X1 + X2 + X3… Read More »

## Minimum and Maximum element of an array which is divisible by a given number k

Given an array, the task is to find the minimum and maximum elements in the array which is divisible by a given number k. Examples:… Read More »

## Find last two digits of sum of N factorials

Given a number N, the task is to find unit and tens places digit of the first N natural numbers factorials, i.e last last two… Read More »

## Value of the series (1^3 + 2^3 + 3^3 + … + n^3) mod 4 for a given n

Given a function f(n) = (13 + 23 + 33 + … + n3), the task is to find the value of f(n) mod 4… Read More »

## Implementation of Wilson Primality test

Given a number N, the task is to check if it is prime or not using Wilson Primality Test. Print ‘1’ isf the number is… Read More »