Created
April 26, 2018 03:10
-
-
Save monksy/3e65efeb1a0ce68c33ac5bcbe02fe8bd to your computer and use it in GitHub Desktop.
Fizzbuzz in scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fizzBuzz(number: Int): String = { | |
| number match { | |
| case z if z % 3 == 0 && z % 5 == 0 => "Fizzbuzz" | |
| case z if z % 3 == 0 => "Fizz" | |
| case z if z % 5 == 0 => "Buzz" | |
| case _ => number.toString | |
| } | |
| } | |
| (1 to 100).foreach(a=> println(fizzBuzz(a))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment