Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- fn divisible(x: i32, divisor: i32) -> i8 {
- if x % divisor == 0 { 1 }
- else { 0 }
- }
- fn fizzbuzz(x: i32) -> String {
- let three_five_nr = (divisible(x, 3), divisible(x, 5), x);
- match three_five_nr{
- (1, 1, _) => "fizzbuzz".to_string(),
- (1, 0, _) => "fizz".to_string(),
- (0, 1, _) => "buzz".to_string(),
- (_, _, nr) => nr.to_string()
- }
- }
- for i in 0..100{
- println!("for {} its {}", i, fizzbuzz(i));
- }
- }
Add Comment
Please, Sign In to add comment