# C# Program to find LCM

You are Here:

## What is Least Common Multiple?

A smallest common multiple of two or more integers.

In general, Least Common Multiple (LCM) is otherwise called as Lowest Common Multiple (LCM) or Smallest Common Multiple (SCM)

Tips: It is recommended to use our online LCM calculator for better understanding.

## Examples

The following table provides few examples of LCM of the given numbers.

NumbersLCM
4, 1020
6, 530
15, 30 , 4590

## LCM of Two Numbers

n the following example, we will find the LCM of the given two numbers (45, 90).

### Example

C# Compiler
using System; namespace myApp { class Program { static void Main(string[] args) { int num1 = 45; int num2 = 90; int max; max = (num1 > num2) ? num1 : num2; // Always true while(true) { if((max % num1 == 0) && (max % num2 == 0)) { Console.Write("LCM of {0} and {1}: {2}", num1, num2, max); break; } ++max; } } } }

### Output

LCM of 45 and 90: 90

## LCM of any Two Given Numbers

In the following example, we will find the LCM of any two given numbers.

### Example

C# Compiler
using System; namespace myApp { class Program { static void Main(string[] args) { int num1, num2, max; Console.Write("Enter positive (int) num1 = "); num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter positive (int) num2 = "); num2 = Convert.ToInt32(Console.ReadLine()); max = (num1 > num2) ? num1 : num2; // Always true while(true) { if((max % num1 == 0) && (max % num2 == 0)) { Console.Write("\nLCM of {0} and {1}: {2}", num1, num2, max); break; } ++max; } } } }

### Output

Enter positive (int) num1 = 25 Enter positive (int) num2 = 50 LCM of 25 and 50: 50

## Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on C# with examples for quick and easy learning.

We are working to cover every Single Concept in C#.