## Prime factors of LCM of array elements

Given an array arr[] such that 1 <= arr[i] <= 10^12, the task is to find prime factors of LCM of array elements. Examples: Input… Read More »

## GCD, LCM and Distributive Property

Given three integers x, y, z, the task is to compute the value of GCD(LCM(x,y), LCM(x,z)). Where, GCD = Greatest Common Divisor, LCM = Least… Read More »

## Smallest number divisible by first n numbers

Given a number n find the smallest number evenly divisible by each number 1 to n. Examples: Input : n = 4 Output : 12… Read More »

## Java Program for Common Divisors of Two Numbers

Given two integer numbers, the task is to find the count of all common divisors of given numbers? Input : a = 12, b =… Read More »

## C++ Program for Common Divisors of Two Numbers

Given two integer numbers, the task is to find the count of all common divisors of given numbers. Input : a = 12, b =… Read More »

## GCD and Fibonacci Numbers

You are given two positive numbers M and N. The task is to print greatest common divisor of M’th and N’th Fibonacci Numbers. The first… Read More »

## Stein’s Algorithm for finding GCD

Stein’s algorithm or binary GCD algorithm is an algorithm that computes the greatest common divisor of two non-negative integers. Stein’s algorithm replaces division with arithmetic… Read More »

## LCM of given array elements

Given an array of n numbers, find LCM of it. Input : {1, 2, 8, 3} Output : 24 Input : {2, 7, 3, 9,… Read More »

## Smallest Subarray with given GCD

Given an array arr[] of n numbers and an integer k, find length of the minimum sub-array with gcd equals to k. Example: Input: arr[]… Read More »

## Euler’s Totient Function

Euler’s Totient function ?(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n, i.e.,… Read More »

## Euclidean algorithms (Basic and Extended)

GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and… Read More »

## Java Program for Basic Euclidean algorithms

GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and… Read More »

## C Program for Basic Euclidean algorithms

GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and… Read More »

## Program to find LCM of two numbers

LCM (Least Common Multiple) of two numbers is the smallest number which can be divided by both numbers. For example LCM of 15 and 20… Read More »

## Program to find GCD or HCF of two numbers

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 »