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

Write a program to find whether a given number is prime or not.

611


1.how to deploy the Maven application in weblogic server? 2.In Real time projects all classes are singleton or some classes only singleton explain? 3.what are the major uses of the designpatterns? 4.explain restful &Soap based services explain?

1655


Colors specified with the notation

1809


hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

1547


can any one suggestion me present which course(except java,.net) has huge demand in the market?

1619






What sysoption determines where the macro facility searches a specific catalog for complied macro?

1651


how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnn 

1659


Diff between IF and where ?

1618


what is session state?

1525


hii I inntrested abt scjp certification but i dont knw abt scjp plz send details abt scjp exam and syllabus.

1393


Can i please VHDL code for D-Latch with clear input ?? (HINT: Set up a “Process” with appropriate sensitivity list to get the desired D-Latch with Clr working.) Inputs and Outputs: entity Lab4b is Port ( Clr, Clk, D : in STD_LOGIC; Q : out STD_LOGIC); end Lab4b;

993


Explain the types of operations? Draw the figure for shift and rotate operations?

2810


What is the merger sort principle and its time complexity.

640


what is web configuration file

1545


Tell me the jobs for the MCA Fresher in delhi, Noida..

1903