In this blog we will learn Find LCM of Two Numbers Using VB.NET.
In this article I will explain how to find the Lowest Common Multiples of two numbers in a VB.NET.
What is a LCM ?
LCM Stands for Lowest Common Multiple of two numbers.
Code for Find LCM of Two Numbers Using VB.NET.
Imports System Module Program Sub Main(args As String()) Dim num1, num2, x, y As Integer, lcm As Integer = 0 Console.Write("Enter the First Number : ") num1 = Integer.Parse(Console.ReadLine()) Console.Write("Enter the Second Number : ") num2 = Integer.Parse(Console.ReadLine()) x = num1 y = num2 While num1 <> num2 If num1 > num2 Then num1 = num1 - num2 Else num2 = num2 - num1 End If End While lcm = (x * y) / num1 Console.Write("Lowest Common Multiple is : " & lcm) Console.ReadLine() End Sub End Module
Advertisement
Output
Advertisement