answersLogoWhite

0

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

10y ago

What else can I help you with?

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.


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.


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.


Write the program in qbasic and add two numbers?

Cls input "enter two no.s ",a,b sum=a+b print "sum = ";sum end

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 many numbers is in a cvv2 code?

Three, An example could be : 000


What are the first three digits in Tennessee phone numbers?

the area code


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.


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 are the three numbers on the back of a credit card called?

The three numbers on the back of a credit card are called the CVV (Card Verification Value) or CVC (Card Verification Code).