Given two integers x and y. In one step, we have to subtract the greatest common divisor of x and y from x and y… Read More
Tag Archives: GCD-LCM
Given an array of positive integers arr[], the task is to find the maximum absolute difference between the pairs from the array such that the… Read More
Given a range of positive integers, find the Greatest Common Divisor (GCD) of the largest and smallest Armstrong numbers within that range. Examples: Input: Range… Read More
Given an array A[] of length N such that A[i] = i for all indices. Also, given two integers K and X. The task is… Read More
Given an array arr[], the task is to find the minimum positive integer x (x > 1) such that for every ai for (0 ≤… Read More
Given two integers n and m. Find the number of continuous pairs possible with gcd(n, m) = 1, wherein each step 1 can be incremented… Read More
Given an array, arr[] of size N, Given M queries and each query consisting of a number X, the task is to subtract X from… Read More
Given arrays A[] and B[] each of length N and A[i] has all the elements from 1 to N, the task is to check if… Read More
Given an integer N, the task is to find a minimum possible Y that satisfies the following condition: Y > N. Y is not divisible… Read More
GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. For example, GCD of… Read More
Given an integer arr[] of length N such that (Ai > 0) for all (1 ≤ i ≤ N) and an integer X. In one… Read More
Given a positive integer arr[] of length L (2 ≤ L ≤ 2000) containing elements from 1 to L in unsorted order and an integer… Read More
Given an array arr[] of size N, the task is to minimize the number of distinct elements in the array after performing the following operation… Read More