Algorithm/BOJ
[BOJ] 2609 최대공약수 최소공배수
yeeendy
2023. 1. 25. 16:30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BOJ2609
{
class Program
{
static void Main(string[] args)
{
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = a[0];
int n2 = a[1];
int temp = 0;
while (n2 != 0)
{
temp = n % n2;
n = n2;
n2 = temp;
if (n2 == 0)
{
Console.WriteLine(n);
break;
}
}
Console.WriteLine(n * a[0] / n * a[1] / n);
}
}
}