Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9
Try first and show attempts if getting any problem.
24th Apr 2020, 6:56 AM
A͢J
A͢J - avatar
+ 1
Alpha Arun please do not post your homework here. The community is not here to do it for you. Thanks and happy coding. https://www.sololearn.com/discuss/1316935/?ref=app
28th Nov 2020, 11:48 PM
BroFar
BroFar - avatar
0
import java.util.Scanner ; public class MyClass { static int hcf(int x,int y) { int a=x; int t; int b=y; if(a<b) { while(b!=0) { t=b; b=a%b; a=t; } return a; } else { while(a!=0) { t=a; a=b%a; b=t; } return b; } } public static void main(String[ ] args) { Scanner s=new Scanner(System .in); int a=s.nextInt(); int b=s.nextInt(); MyClass d=new MyClass(); int h=hcf(a,b); System .out.println("hcf="+h); System .out.println("lcm="+((a*b)/h)); } }
23rd Oct 2020, 7:28 PM
Sanjay Modi
Sanjay Modi - avatar