blob: 0825ceadd681fae79c422f5643d63c76a86a9563 (
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
28
29
30
31
32
|
using System;
namespace GCD {
class Program {
static uint gcd2(uint a, uint b) {
uint c;
while (b != 0) {
c = b;
b = a % b;
a = c;
}
return a;
}
static uint gcdn(uint [] n) {
uint r = n[0];
for (int i = 1; i < n.Length; i++)
r = gcd2(r, n[i]);
return r;
}
static void Main(string [] argv) {
uint [] a = Array.ConvertAll<string, uint>(argv,
new Converter<string, uint>
(delegate(string s) {return uint.Parse(s);})
);
Console.WriteLine("{0}", gcdn(a));
}
}
}
|