# Tag Archives: LCM

## Find Landau’s function for a given number N

Given an integer N, the task is to find the Landau’s Function of the number N. In number theory, The Landau’s function finds the largest… Read More »

## Find two numbers with given sum and maximum possible LCM

Given an integer X, the task is to find two integers A and B such that sum of these two numbers is X and the… Read More »

## Minimum LCM of all subarrays of length at least 2

Given an array arr[] of N positive integers. The task is to find the minimum LCM of all subarrays of size greater than 1. Examples: … Read More »

## Maximize the sum of modulus with every Array element

Given an array A[] consisting of N positive integers, the task is to find the maximum possible value of: F(M) = M % A +… Read More »

## Number of ways to change the Array such that largest element is LCM of array

Given an array arr[], the task is to count the number of the unique arrays can be formed by updating the elements of the given… Read More »

## Program to find the LCM of two prime numbers

Given two prime numbers N and M, the task is to find the Least Common Multiple(LCM) of the two given prime numbers. Examples: Input: N… Read More »

## Find element that maximizes LCM of an Array in the range 1 to M

Given an array arr of size N containing numbers in the range [1, M], the task is to find an element, in the range [1,… Read More »

## Minimum possible value of max(A, B) such that LCM(A, B) = C

Given an integer C, the task is to find the minimum possible value of max(A, B) such that LCM(A, B) = C. Examples: Input: C… Read More »

## Find two numbers with the given LCM and minimum possible difference

Given an integer X, the task is to find two integers A and B such that LCM(A, B) = X and the difference between the… Read More »

## Remove an element to minimize the LCM of the given array

Given an array arr[] of length N ≥ 2. The task is to remove an element from the given array such that the LCM of… Read More »

## Longest sub-sequence with minimum LCM

Given an array arr[] of length N, the task is to find the length of the longest sub-sequence with minimum possible LCM. Examples: Input: arr[]… Read More »

## Maximum LCM among all pairs (i, j) of first N natural numbers

Given a positive integer N > 1, the task is to find the maximum LCM among all the pairs (i, j) such that i <… Read More »

## Minimum integer such that it leaves a remainder 1 on dividing with any element from the range [2, N]

Given an integer N, the task is to find the minimum possible integer X such that X % M = 1 for all M from… Read More »

## Find the longest subsequence of an array having LCM at most K

Given an array arr[] of N elements and a positive integer K. The task is to find the longest sub-sequence in the array having LCM… Read More »

## Count pairs (i,j) such that (i+j) is divisible by A and B both

Given n, m, A and B. The task is to count the number of pairs of integers (x, y) such that 1 x n and… Read More »