Smallest Special Prime which is greater than or equal to a given number

Given a number N. The task is to find the smallest special prime which is greater than or equal to N. A special prime is… Read More »

Find a permutation such that number of indices for which gcd(p[i], i) > 1 is exactly K

Given two integers N and K, the task is to find a permutation of integers from the range [1, N] such that the number of… Read More »

Minimum number of given moves required to make N divisible by 25

Given a number N(1 ≤ N ≤ 1018) without leading zeros. The task is to find the minimum number of moves required to make N… Read More »

Count primes that can be expressed as sum of two consecutive primes and 1

Given a number N. The task is to count the number of prime numbers from 2 to N that can be expressed as a sum… Read More »

Maximum positive integer divisible by C and is in the range [A, B]

Given three positive integers A, B and C. The task is to find the maximum integer X > 0 such that: X % C =… Read More »

Sum of bitwise AND of all subarrays

Given an array consisting of N positive integers, find the sum of bit-wise and of all possible sub-arrays of the array. Examples: Input : arr[]… Read More »

Sum of XOR of all subarrays

Given an array containing N positive integers, the task is to find the sum of XOR of all sub-arrays of the array. Examples: Input :… Read More »

Find a permutation of 2N numbers such that the result of given expression is exactly 2K

Given two integers N and K, the task is to find a permutation of first 2*N natural numbers such that the following equation is satisfied.… Read More »

Find a positive number M such that gcd(N^M, N&M) is maximum

Given a number N, the task is to find a positive number M such that gcd(N^M, N&M) is the maximum possible and M < N.… Read More »

Source to destination in 2-D path with fixed sized jumps

Given the source point and the destination point of the path and two integers x and y. The task is to check whether it is… Read More »

Minimize the sum of the squares of the sum of elements of each group the array is divided into

Given an array consisting of even number of elements, the task is to divide the array into M group of elements (every group must contain… Read More »

Maximum length subsequence such that adjacent elements in the subsequence have a common factor

Given an array arr[], the task is to find the maximum length of a subsequence such that the adjacent elements in the subsequence have a… Read More »

Count of pairs (x, y) in an array such that x < y

Given an array of N distinct integers, the task is to find the number of pairs (x, y) such that x < y. Example: Input:… Read More »

Check whether the point (x, y) lies on a given line

Given the values of m and c for the equation of a line y = (m * x) + c, the task is to find… Read More »

Numbers less than N that are perfect cubes and the sum of their digits reduced to a single digit is 1

Given a number n, the task is to print all the numbers less than or equal to n which are perfect cubes as well as… Read More »