answersLogoWhite

0


Best Answer

For this you will need a couple of helper algorithms. The first is the GCD (greatest common divisor) which is expressed as follows:

procedure GCD (a, b) is

input: natural numbers a and b

while a<>b do

if a>b

let a be a-b

else

let b be b-a

end if

end while

return a

The second algorithm is the LCM (least common multiple) of two numbers:

procedure LCM (a, b) is

input: natural numbers a and b return (a*b) / GCD (a, b)

Now that you can calculate the GCD and LCM of any two natural numbers, you can calculate the LCM of any three natural numbers as follows:

procedure LCM3 (a, b, c) is

input: natural numbers a, b and c return LCM (LCM (a, b), c)

Note that the LCM of three numbers first calculates the LCM of two of those numbers (a and b) and then calculates the LCM of that result along with the third number (c). That is, if the three numbers were 8, 9 and 21, the LCM of 8 and 9 is 72 and the LCM of 72 and 21 is 504. Thus the LCM of 8, 9 and 21 is 504.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you calculate LCM of three numbers by pesudo code?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the disadvantage of pesudo code?

we have no disadvantages by pseudo-codes. in fact these help the programmers to increase the efficiency in programming.


How do you write pesudo code?

Pseudo-code is not real code insofar as there is no standard and no compilers or interpreters that can reliably convert pseudo-code into machine code. It is a free-form language used for illustrative purposes only. Pseudo-code is typically used to express algorithms using a program-like language that can be easily adapted to any specific language. The choice of wording is entirely up to the author but must be used consistently and in an easy-to-understand manner, using concepts that are common across all languages including structured loops, control statements and functions. Anyone with any programming experience should be able to easily convert pseudo-code into real code without any major difficulty.


How do you calculate factors of a number using python programming language?

An easy way to calculate all the factors of whole numbers is to iterate from 1 to that number and check if the remainder is zero using the "%" operation. def getFactors(num): """Return the factors of a whole number""" factors = [] for i in range(1,num+1): if num%i == 0: factors.append(i) return factors Factoring negative numbers and zero simply requires a few more tweaks to the code.


What is the benefit of using function.llustrate different ways of passing argument to function in c plus plus?

Functions are used to reduce the lines of code and the complexity of the code. For an instance let us suppose that you want to calculate the factorial of numbers at different times in a program. There are two ways to do this 1. Write a 4-5 line code every time you want to calculate factorial. 2. Write a function of 4-5 lines which calculates the factorial and call that function every time you need to calculate factorial by just writing a single line. In C++ you can pass the variable, address of the variable or a reference to the variable in a function


Can you help to create a code for Visual Basic 6.0 that accepts three numbers and display it in ascending order coz im a beginner?

Look into bubble sort, it is one of the simplest sorting algorithms.

Related questions

What is the disadvantage of pesudo code?

we have no disadvantages by pseudo-codes. in fact these help the programmers to increase the efficiency in programming.


What area code for phone numbers has 847 has the first three numbers in the US?

847 is a prefix for what area code in United States for phones numbers


How many numbers are in the Puerto Rico zip code?

Three


When you get an AR code for final fantasy XII what does the three question marks mean?

they mean that you need to input three more letters/numbers to the code in that space for a diffirent result. the three other letters/numbers are usually underneath the code. good luck!


How do you find average of three numbers in 8085 microprocessor code in a given address and data?

You add the three numbers, then divide the result by 3.


What are the first three digits in Tennessee phone numbers?

the area code


How many numbers is in a cvv2 code?

Three, An example could be : 000


How many numbers does a credit card security code have to have?

Most cases it is three, and they are the last numbers on the back of your card.


What is Visa security code?

On the back of your card there should be a strip with numbers on it. The security code is the last three digits. :)


If you live in Minnesota what would the first three numbers of your phone number be?

The first three numbers of your phone number would be the area code, but Minnesota has several.


Is the security code on back of a Visa card the first set of four numbers or the last three numbers?

The security code on any credit card would be the last set of digits on back of the card with is the three digit number


What is American express verification code?

The American Express verification code is the three numbers of back of the card at the end of your account number.