LCM calculator

Calculate lcm calculator with clear inputs and assumptions.

Calculate lcm calculator with clear inputs and assumptions.

Your inputs stay in your browser. Displayed results are rounded to a maximum of 12 significant digits.

Method and assumptions

Method version 1.0.0 · Updated

Calculate

Formula: Calculate lcm calculator with clear inputs and assumptions.

Calculate lcm calculator with clear inputs and assumptions.

a
Integer A
b
Integer B

Results are estimates where noted and depend on the entered assumptions.

Calculate with code

These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.

JavaScript
const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
const lcm = (a, b) => Math.abs(a / gcd(a, b) * b);
console.log(lcm(12, 18)); // 36
TypeScript
const gcd = (a: number, b: number): number => b === 0 ? a : gcd(b, a % b);
const lcm = (a: number, b: number) => Math.abs(a / gcd(a, b) * b);
console.log(lcm(12, 18)); // 36
Python
from math import gcd
a, b = 12, 18
print(abs(a // gcd(a, b) * b))  # 36
Java
long a = 12, b = 18;
long gcd = java.math.BigInteger.valueOf(a).gcd(java.math.BigInteger.valueOf(b)).longValue();
System.out.println(Math.abs(a / gcd * b)); // 36
C#
long a = 12, b = 18;
long gcd = System.Numerics.BigInteger.GreatestCommonDivisor(a, b);
Console.WriteLine(Math.Abs(a / gcd * b)); // 36