Coin de Gamma
2 years ago
1 changed files with 23 additions and 0 deletions
@ -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…
Reference in new issue