RosettaCodeData/Task/Repeat/Rust/repeat-6.rust

12 lines
187 B
Plaintext

fn repeat(f: impl FnMut(usize), n: usize) {
(0..n).for_each(f);
}
fn main() {
let mut mult = 1;
repeat(|x| {
print!("{};", x * mult);
mult += x;
}, 5);
}