summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcd.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/gcd.rs b/gcd.rs
index 9e73a44..7b5e753 100644
--- a/gcd.rs
+++ b/gcd.rs
@@ -1,17 +1,14 @@
use std::env;
-fn gcd2(a: u64, b: u64) -> u64
+fn gcd2(mut a: u64, mut b: u64) -> u64
{
- let mut a1 = a;
- let mut b1 = b;
-
- while b1 != 0 {
- let c1 = b1;
- b1 = a1 % b1;
- a1 = c1;
+ while b != 0 {
+ let c = b;
+ b = a % b;
+ a = c;
}
- a1
+ a
}