##
Find pair with maximum GCD in an array
July 23, 2017

We are given an array of positive integers. Find the pair in array with maximum GCD. Examples: Input : arr[] : { 1 2 3… Read More »

July 23, 2017

We are given an array of positive integers. Find the pair in array with maximum GCD. Examples: Input : arr[] : { 1 2 3… Read More »

July 12, 2017

Given a number n. We need find the number of ordered pairs of a and b such gcd(a, b) is b itself Examples: Input :… Read More »

June 22, 2017

Consider circular track with n points marked as 1, 2, …n. A person is initially placed on point k. The person moves m > 0,… Read More »

June 20, 2017

We need to find number of possible pairs (a, b) such that GCD(a, b) is equal to given G and LCM (a, b) such that… Read More »

June 16, 2017

Given four integers m, n, a, b. Find how many integers from range m to n are divisible by a or b. Input: 3 11… Read More »

June 10, 2017

Given n integers, we need to find size of the largest subset with GCD equal to 1. Input Constraint : n <= 10^5 A[i] <=… Read More »

June 4, 2017

Given a positive number N. The task is to find maximum sum of distinct numbers such that the LCM of all these numbers is equal… Read More »

May 30, 2017

Given an array and a number k, the task is to find if LCM of the array is divisible by k or not. Examples: Input… Read More »

May 26, 2017

Given an array of n numbers and a number of queries are also given. Each query will be represented by two integers l, r. The… Read More »

April 18, 2017

Given an array of positive integers, find LCM of the elements present in array. Examples: Input : arr[] = {1, 2, 3, 4, 28} Output… Read More »

March 27, 2017

Given an array of numbers, find GCD of the array elements. In a previous post we find GCD of two number. Examples: Input : arr[]… Read More »

March 11, 2017

Given a number N, find sum of all GCDs that can be formed by selecting all the pairs from 1 to N. Input : 4… Read More »

March 3, 2017

Given an array arr[], find the largest subsequence such that GCD of all those subsequence are greater than 1. For exampple:- Input: 3, 6, 2,… Read More »

February 21, 2017

Given two points pointU and pointV in XY-space, we need to find a point which has integer coordinates and lies on a line going through… Read More »

February 20, 2017

Given an array of integers and an array of prime numbers. The task is to find if it is possible to make all the elements… Read More »