백준: 13241(최소공배수)

강지안·2023년 6월 7일
0

baekjoon

목록 보기
54/186

문제

코드

import java.io.*;

public class q13241 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] input = br.readLine().split(" ");
        long A = Long.parseLong(input[0]);
        long B = Long.parseLong(input[1]);
        
        bw.write(A * B / getGcd(A,B) + "\n");
        bw.flush();
    }
    public static long getGcd(long a, long b) {
        if(b == 0) return a;
        else return getGcd(b, a%b);
    }
}

0개의 댓글