Write a Pseudo Code to fins the LCM of two given numbers

Answer Posted / khadanga

public class LCM {

public static void main(String a[]){
test(0,9);
}

static void test(int a,int b){
if(a==0 || b==0){
return;
}
int n;
int increment;
if(a>b){
n = a;
increment = a;
}else{
n = b;
increment = b;
}

while(true){
if(n%a == 0 && n%b == 0){
break;
}else if(n > (a*b)){
n = a*b;
break;
}else{
n = n+increment;
}
}

System.out.println("LCM for "+a+" and "+b+" is "+n);
}

}

Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hai, My name is nisha.I have NIC exam.If anybody Knows NIC previous paper pattern pls send me to nishanairp@gmail.com

1741


Write a shell program where you enter a number which corresponds to K.M. Find out the corresponding values in m, cm, inches, and feet. Hints:- 1 k.m= 1000 m 1 m= 100 cm 1 inches= 2.54 cm. 1 feet= 12 inches

1518


write a sql qwery which include joining of two tables 4 marks mainframe

1486


Hi Guys, This is Rama, right now I am working as a Software Test Engineer in Gurgoan and I have over all 3 years of testing expoeriance. Right now I am looking for a change. Can any body help me out to find a job in south india. Thanks in Advance

1412


In an customer exit (include Z) program, only the last record is getting fetched. The exit is getting called after pressing save button. What to write for fetching the first record ? Before saved to a SAP table how can i call all these records in an itab in the exit ?

1511






what is the use MDM(Master Data Management)and meaning

1901


why we need to take u?

1672


which worker is involved in all the phases of SDLC?

1699


what is the meaning of without standing arrears?

9855


what is radio button? Plz show code this! how will select radio buttons to go next window Forms? Supose o radio button1 o radio button2 o radio button3 o radio button4 how will coding this? Plz explain this!

2899


what is the work of 1tier,2tier,&ntier? Plz Explain it!

2030


what is apt_dump_score in datastage where it is useful

1491


what is an INI file?

1593


what is dot net framework

2340


in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'

1767