# Tag Archives: GCD-LCM

## Find the ratio of LCM to GCD of a given Array

Given an array arr[] of positive integers, the task is to find the ratio of LCM and GCD of the given array. Examples: Input: arr[]… Read More »

## Find pair with maximum GCD for integers in range 2 to N

Given a number N, the task is to find a pair of integers in the range [2, N] with maximum GCD. Examples: Input: N =… Read More »

## Count of triplets in a given Array having GCD K

Given an integer array arr[] and an integer K, the task is to count all triplets whose GCD is equal to K. Examples: Input: arr[]… Read More »

## Count all pairs of divisors of a number N whose sum is coprime with N

Given an integer N, the task is to count all pairs of divisors of N such that the sum of each pair is coprime with… Read More »

## Find GCD of each subtree of a given node in an N-ary Tree for Q queries

Given an N-ary Tree containing N nodes, values associated with each node and Q queries, where each query contains a single node. The task is… Read More »

## Probability that an arbitrary positive divisor of 10^X is an integral multiple of 10^Y

Given two numbers X and Y, the task is to find the probability that an arbitrary positive divisor of 10X is an integral multiple of… Read More »

## Minimum LCM of all pairs in a given array

Given an array arr[] of size N, the task is to find the minimum LCM (Least Common Multiple) of all unique pairs in the given… Read More »

## Print all distinct Coprime sets possible from 1 to N

Given an integer N, the task is to find all distinct co-prime sets up to the given integer N such that an element doesn’t appear… Read More »

## Sum of GCD of all numbers upto N with N itself

Given an integer N, the task is to find the sum of Greatest Common Divisors of all numbers up to N with N itself. Examples:… Read More »

## Find the GCD of LCM of all unique pairs in an Array

Given an integer array arr[] of size N, the task is to find the GCD of LCM of all unique pair (i, j) of the… Read More »

## Print any pair of integers with sum of GCD and LCM equals to N

Given an integer N, the task is to print any pair of integers that have the sum of GCD and LCM equal to N. Examples:… Read More »

## Length of longest subarray of length at least 2 with maximum GCD

Given an array arr[] of length N, the task is the find the length of longest subarray of length at least 2 with maximum possible… Read More »

## Split N natural numbers into two sets having GCD of their sums greater than 1

Given an integer N, the task is to create two sets of distinct elements from 1 to N such that the gcd of their respective… Read More »

## Check if the square of a number is divisible by K or not

Given two integers, X and K, the task is to find if X2 is divisible by K or not. Here, both K and X can… Read More »

## Must do Math for Competitive Programming

Competitive Programming (CP) doesn’t typically require to know high-level calculus or some rocket science. But there are some concepts and tricks which are sufficient most… Read More »