View Code of Problem 59

import java.util.*;
public class Main {
	public static void main(String[] args)
	{
	 Scanner sc = new Scanner(System.in);
	 int  a = sc.nextInt();
	 int  b = sc.nextInt();
	 int d =a;
	 int e=b;
	 int max= 0;
	 int min = 0;
	 int c = 0;
	 while(b%a!=0) {
		 c=b%a;
		 b=a;
		 a=c;
	 }
	 max=c;
	 min = d*e/max;
	 System.out.print(min+" "+max);
	}
}

Double click to view unformatted code.


Back to problem 59