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

how we can know the funcions available in a class recording java?

1946


what is the filters in biztakk server? where it can use?

1837


How to set on/off a group of indicators in a single statement?

1570


what is the basic and unique feature of dotnet

1922


how to add a new table with variables and thier values into a imported file uisng proc import?

1643






Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fit" instead of the number and for the multiples of five print "Bit". For numbers which are multiples of both three and five print "FitBit".

2152


what is web configuration file

1747


how sap is different from other software ?

1863


how pseudo column works?

1904


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!

3090


Bonjour, svp je veut voir comment envoyer un mail en java et comment changer le droit d'accé d'un fichier en java: de lecture en lecture/écriture et merci d'avance ;)

1918


where is available in this mantis toturials?

1804


Plz sent me in .net 2.0 interview Question & answers?

1873


Difference between views and index in sas programming

1206


HOW TO FIND NUMBER OF TWOS IN N!(N FACTORIAL)??

1982