A little code cleanup
This commit is contained in:
parent
e148271a77
commit
588ddb088d
@ -1,16 +1,16 @@
|
|||||||
pub fn gcd(mut n: u64, mut m: u64) -> u64 {
|
pub fn gcd(mut a: u64, mut b: u64) -> u64 {
|
||||||
assert!(n != 0 && m != 0);
|
assert!(a != 0 && b != 0);
|
||||||
|
|
||||||
while m != 0 {
|
while b != 0 {
|
||||||
if m < n {
|
if b < a {
|
||||||
let t = m;
|
let temp = b;
|
||||||
m = n;
|
b = a;
|
||||||
n = t;
|
a = temp;
|
||||||
}
|
}
|
||||||
m = m % n;
|
b = b % a;
|
||||||
}
|
}
|
||||||
|
|
||||||
n
|
a
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -5,7 +5,7 @@ authors = ["Timothy Warren <tim@timshomepage.net>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gcd = { path = "../gcd", version = "0.1.0" }
|
gcd = { path = "../gcd" }
|
||||||
iron = "0.5.1"
|
iron = "0.5.1"
|
||||||
mime = "0.2.3"
|
mime = "0.2.3"
|
||||||
router = "0.5.1"
|
router = "0.5.1"
|
||||||
|
@ -82,7 +82,7 @@ fn post_gcd(request: &mut Request) -> IronResult<Response> {
|
|||||||
response.set_mut(status::Ok);
|
response.set_mut(status::Ok);
|
||||||
response.set_mut(mime!(Text/Html; Charset=Utf8));
|
response.set_mut(mime!(Text/Html; Charset=Utf8));
|
||||||
response.set_mut(
|
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)
|
Ok(response)
|
||||||
|
Loading…
Reference in New Issue
Block a user