Guest User

Untitled

a guest
Nov 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. fn main() {
  2.  
  3. fn divisible(x: i32, divisor: i32) -> i8 {
  4. if x % divisor == 0 { 1 }
  5. else { 0 }
  6. }
  7.  
  8. fn fizzbuzz(x: i32) -> String {
  9. let three_five_nr = (divisible(x, 3), divisible(x, 5), x);
  10.  
  11. match three_five_nr{
  12. (1, 1, _) => "fizzbuzz".to_string(),
  13. (1, 0, _) => "fizz".to_string(),
  14. (0, 1, _) => "buzz".to_string(),
  15. (_, _, nr) => nr.to_string()
  16. }
  17. }
  18.  
  19. for i in 0..100{
  20. println!("for {} its {}", i, fizzbuzz(i));
  21. }
  22. }
Add Comment
Please, Sign In to add comment