Browse Source

A little code cleanup

master
Timothy Warren 7 months ago
parent
commit
588ddb088d
3 changed files with 11 additions and 11 deletions
  1. 9
    9
      gcd/src/lib.rs
  2. 1
    1
      iron-gcd/Cargo.toml
  3. 1
    1
      iron-gcd/src/main.rs

+ 9
- 9
gcd/src/lib.rs View File

@@ -1,16 +1,16 @@
1
-pub fn gcd(mut n: u64, mut m: u64) -> u64 {
2
-    assert!(n != 0 && m != 0);
1
+pub fn gcd(mut a: u64, mut b: u64) -> u64 {
2
+    assert!(a != 0 && b != 0);
3 3
 
4
-    while m != 0 {
5
-        if m < n {
6
-            let t = m;
7
-            m = n;
8
-            n = t;
4
+    while b != 0 {
5
+        if b < a {
6
+            let temp = b;
7
+            b = a;
8
+            a = temp;
9 9
         }
10
-        m = m % n;
10
+        b = b % a;
11 11
     }
12 12
 
13
-    n
13
+    a
14 14
 }
15 15
 
16 16
 #[cfg(test)]

+ 1
- 1
iron-gcd/Cargo.toml View File

@@ -5,7 +5,7 @@ authors = ["Timothy Warren <tim@timshomepage.net>"]
5 5
 edition = "2018"
6 6
 
7 7
 [dependencies]
8
-gcd = { path = "../gcd", version = "0.1.0" }
8
+gcd = { path = "../gcd" }
9 9
 iron = "0.5.1"
10 10
 mime = "0.2.3"
11 11
 router = "0.5.1"

+ 1
- 1
iron-gcd/src/main.rs View File

@@ -82,7 +82,7 @@ fn post_gcd(request: &mut Request) -> IronResult<Response> {
82 82
     response.set_mut(status::Ok);
83 83
     response.set_mut(mime!(Text/Html; Charset=Utf8));
84 84
     response.set_mut(
85
-        format!("The greatest common divisor of the numbers {:?} is <B>{}</b>\n", numbers, d)
85
+        format!("The greatest common divisor of the numbers {:?} is <strong>{}</strong>\n", numbers, d)
86 86
     );
87 87
 
88 88
     Ok(response)

Loading…
Cancel
Save