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
You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: delete a character, insert a character, replace a character. Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)
Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)
Given: coordinates of rectangle-> left bottom and right top points. the rectangles create a hole.Find the maximum area of the hole. eg. 4 rectangles create a hole in between. find its area.
can we allocate memory for interface? if no then why?
how to remove header and footer in jcl using sort utility
What is the merger sort principle and its time complexity.
what are the missinschema properties and should we pass primary key in select command
when we use mantis? how learn mantis?
any drawback are there in mantis?
Is class is a abstract datatype in java?
i want to insert textbox value to sql db. i have only one text box but store four values. ple give any one give sample code in asp.net c#..
Find out the roles which gives access to all tables in SAP? Thanks in advance.
How do i find out the number of parameters passed into function?
ok how would i do the following extract from a file i have ssns = 267907230 which are in column 7 into a separate data set then create a 2nd job step to extract from the data set created the following "fund code" which is in column 31 and is 113 into yet another data set
how can we maintain the previous version scripts to new version.