Skip to content

Tag Archives: sieve

Given three integers A, B, and C, the task is to find the minimum possible value of |A – X| + |B – Y| +… Read More
Given an array arr[], the task is to find the longest subarray whose sum is a prime number. Examples: Input:   arr[ ] = {1, 4,… Read More
Given an array arr[] of N integers, the task is to find the number of unordered pairs (i, j) in the array such that the… Read More
Given an array A[] with N integers, for each integer A[i] in the array, the task is to find the number of integers A[j] (j… Read More
Given an array arr[] consisting of N positive integers, the task is to find the number of pairs such that the Greatest Common Divisor(GCD) of… Read More
Given an integer N, you have to find two proper factors of N such that their sum is coprime with the given integer N. If… Read More
Given an positive integer N, the task is to find the number of triplets (X, Y, Z) such that the sum of product of any… Read More
Given a positive integer N, the task is to count the number of N-digit numbers whose sum of digits is a prime number. Examples: Input:… Read More
Given a positive integer N, the task is to generate a sequence say arr[] of maximum length having all elements at least 2 such that… Read More
Given a number N (N > 6), the task is to print the prime factorization of a number Z, where Z is the product of… Read More
Given an integer array A[] of size N, the task is to find the prime numbers just less and just greater than A[i] (for all… Read More
Given an array arr[] consisting of N integers such that each array element arr[i] represent coefficients of a polynomial expression starting with the highest degree(A[0].X(N… Read More
Given an integer N, repeatedly choose two distinct integers from the range 2 to N and if their GCD is found to be greater than… Read More
Given a positive integer N, the task is to calculate the Bitwise XOR of first N numbers which are a product of exactly two distinct… Read More