Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created December 14, 2025 02:26
Show Gist options
  • Select an option

  • Save icub3d/967bd95ea8719455dab644b828d0a63e to your computer and use it in GitHub Desktop.

Select an option

Save icub3d/967bd95ea8719455dab644b828d0a63e to your computer and use it in GitHub Desktop.
Kattis fizzbuzz
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut vv = s.split_whitespace().map(|v| v.parse::<usize>().unwrap());
let (x, y, n) = (vv.next().unwrap(), vv.next().unwrap(), vv.next().unwrap());
for i in 1..=n {
if i % x == 0 && i % y == 0 {
println!("FizzBuzz");
} else if i % x == 0 {
println!("Fizz");
} else if i % y == 0 {
println!("Buzz");
} else {
println!("{i}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment