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
Hi guyes, I have cleared 2 technical rounds with cts for liferay and java techonologies, i have client round next week, please tell me how to prepare for this what questions i should be ready to face?
is it possible to desable particular parameter of the normal orcle report based on some condition ?????? if yes,wht is the function for desabling a parameter...
what are all the validation we need to perform in data stage?
shall we execute our java programmes in jre
Which language they use during interview?
What r the attributes using in Win Runner?
could you please tell me how to draw the calibration curve for HPLC {the software which we are using}?
Difference between delegates and Events?
Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage
What are two of your strengths that you will bring to our QA/testing team?
Write a shell program. Enter number of days from keyboard. Find out the number of years, month and days it contains
how to generate dsnless connectivity in j2ee
Code for display the images from drive using vb 6.0?
Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number
How do you initialize a static member of a class with return value of some function?