Tag Archives: GCD

Find GCD of two numbers

Given two numbers A and B, the task is to calculate GCD of A and B. Examples: Input : A = 4, B = 6 Output : 2 Input : A = 5, B = 10 Output : 5 GCD (Greatest Common Divisor) of two number is the largest number that divides both of them. A simple solution… Read More »

LCM of given array elements

Given an array of size n, your task is to find the least common multiple or LCM of all the elements of the array. Examples: Input : arr = [ 8, 9, 21] Output : 504 Input : arr = [ 2, 4, 3, 8] Output : 24 RECOMMENDED: Maximum Length Subsequence from Ticket Prices Array Method-1: Prime… Read More »