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

12 lines
187 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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);
}