home ~ projects ~ socials

Loop Through Numbers In A Range With A Given Step In Rust

fn main() {
  for num in (1..=10).step_by(2) {
    println!("{}", num);
  }
}
Output:
1
3
5
7
9
-- end of line --