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 {
|
||||
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)]
|
||||
|
@ -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"
|
||||
|
@ -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…
Reference in New Issue
Block a user