Browse Source

005 ok

master
Coin de Gamma 2 years ago
parent
commit
780c879e2d
  1. 23
      005/solution.rs

23
005/solution.rs

@ -0,0 +1,23 @@
fn gcd(a: i32, b: i32) -> i32 {
let mut max = a.max(b);
let mut min = a.min(b);
loop {
let res = max % min;
if res == 0 { return min; }
max = min;
min = res;
}
}
fn main() {
let n = 20;
let mut p = 1;
for k in 1..=n {
let q = gcd(p, k);
let m = k / q;
p *= m;
println!("{} -> {}", k, p);
}
}
Loading…
Cancel
Save