Question 1

LCM – Least Common Multiple of both the numbers


  • Have any common multiple except 1
  • Always greater than or equal to the maximum number


#1.Find the maximum and minimum number

#2.Loop from 1 till the minimum number

#3.Find the multiple of the maximum number

#4.Check the multiple of maximum number is also a multiple of minimum number

#5.If the multiple is exactly divisible, then it is the LCM and return from the loop

#6.If the multiple is not exactly divisible, then continue with the loop


Ex: LCM(5,7)




max=7, min=5

for(int i=1;i<min;i++) multiple=i*max If(multiple%min==0) lcm=multiple
1;1<=5;1++ 1*7=7 7%5=2==0(false)
2;2<=5;2++ 2*7=14 14%5=4==0(false)
3;3<=5;3++ 3*7=21 21%5=1==0(false)
4;4<=5;4++ 4*7=28 28%5=3==0(false)
5;5<=5;5++ 5*7=35 35%5=0==0(true) lcm=35




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s