最大公約數與最小公倍數
Problem Description
Input
Output
第二行輸出最小公倍數。
Example Input
64 48
Example Output
16 192
01 |
import java.util.*; |
02 |
import java.lang.*; |
03 |
public class Main
{ |
04 |
public static void main(String
args[]){ |
05 |
Scanner
input = new Scanner(System.in); |
06 |
int a
= input.nextInt(); |
07 |
int b
= input.nextInt(); |
08 |
int n
= a*b; |
09 |
int b1
=b; |
10 |
while (b!= 0 ){ |
11 |
if (b!= 0 ){ |
12 |
b1
= b; |
13 |
} |
14 |
|
15 |
b
= a%b; |
16 |
} |
17 |
System.out.println(b1); |
18 |
System.out.println(n/b1); |
19 |
} |
20 |
} |
21 |