BOJ - 2609 - 최대공약수와 최소공배수

Updated:

import sys

def gcd(a, b) :
    if b==0:
        return a
    else :
        return gcd(b,a%b)

def lcm(a, b) :
    g = gcd(a,b)
    return int(g*(a/g)*(b/g))

def solution():
    A, B = map(int, sys.stdin.readline().split())
    print(gcd(A, B))
    print(lcm(A, B))
solution()

https://www.acmicpc.net/problem/2609

Categories:

Updated:

Leave a comment