Do you wish to register an account?
Browse Source

A little code cleanup

master
Timothy Warren 11 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 @@
pub fn gcd(mut n: u64, mut m: u64) -> u64 {
assert!(n != 0 && m != 0);
pub fn gcd(mut a: u64, mut b: u64) -> u64 {
assert!(a != 0 && b != 0);

while m != 0 {
if m < n {
let t = m;
m = n;
n = t;
while b != 0 {
if b < a {
let temp = b;
b = a;
a = temp;
}
m = m % n;
b = b % a;
}

n
a
}

#[cfg(test)]

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

@@ -5,7 +5,7 @@ authors = ["Timothy Warren <tim@timshomepage.net>"]
edition = "2018"

[dependencies]
gcd = { path = "../gcd", version = "0.1.0" }
gcd = { path = "../gcd" }
iron = "0.5.1"
mime = "0.2.3"
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> {
response.set_mut(status::Ok);
response.set_mut(mime!(Text/Html; Charset=Utf8));
response.set_mut(
format!("The greatest common divisor of the numbers {:?} is <B>{}</b>\n", numbers, d)
format!("The greatest common divisor of the numbers {:?} is <strong>{}</strong>\n", numbers, d)
);

Ok(response)

Loading…
Cancel
Save