Blame view

P96564_en/S001-AC.cc 514 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>

using namespace std;


long int gcd(long  a, long  b)
{
	long  res;
	while(b)
	{
		res = b;
		b = a % b;
		a = res;
	}
	return res;
}
long  mcm(long  a, long  b)
{
	return (a / gcd(a, b))*b;
}

int main()
{
	int n;
	long  a;
	long  b;
	while(1)
	{
		cin >> n;
		if(n)
		{
			if(n == 1)
			{
				cin >> a;
				cout << a << endl;
				continue;
			}
			cin >> a;
			for(int i = 0; i < n-1; i++)
			{
				cin >> b;
				a = mcm(a,b);
			}
			cout << a << endl;
		}
		else
		{
			return 0;
		}
	}
}