summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcd.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/gcd.rs b/gcd.rs
index a07377b..95cc865 100644
--- a/gcd.rs
+++ b/gcd.rs
@@ -1,24 +1,20 @@
use std::env;
-fn gcd2(mut a: u64, mut b: u64) -> u64
-{
- while b != 0 {
- let c = b;
- b = a % b;
- a = c;
- }
+fn gcd2(mut a: u64, mut b: u64) -> u64 {
+ while b != 0 {
+ let c = b;
+ b = a % b;
+ a = c;
+ }
- a
+ a
}
+fn main() {
+ // XXX skip(1) to skip program name:
+ let nums = env::args().skip(1).map(|s| s.parse().unwrap());
-fn main ()
-{
- // XXX skip(1) to skip program name:
- let nums = env::args().skip(1).map(|s| s.parse().unwrap());
+ let gcd = nums.fold(0, gcd2);
- let gcd = nums.fold(0, gcd2);
-
- println!("{}", gcd);
+ println!("{}", gcd);
}
-