blob: 325e27ab65860e6a970bd79d708288d49b262dfe (
plain)
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
|
using System;
using System.Linq;
class Program {
static ulong gcd2(ulong a, ulong b) {
ulong c;
while (b != 0) {
c = b;
b = a % b;
a = c;
}
return a;
}
static ulong gcdn(ulong[] nums) {
return nums.Aggregate(0UL, (gcd, n) => gcd2(gcd, n));
}
static void Main(string[] argv) {
ulong[] nums = Array.ConvertAll<string, ulong>(
argv, new Converter<string, ulong>(
delegate(string s) { return ulong.Parse(s); }));
if (nums.Length > 0)
Console.WriteLine("{0}", gcdn(nums));
}
}
|