You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
391 B
23 lines
391 B
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); |
|
} |
|
|
|
}
|
|
|