Skip to content

Instantly share code, notes, and snippets.

@liquidz
Forked from modalsoul/fizzbuzz.scala
Created October 11, 2011 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liquidz/1277976 to your computer and use it in GitHub Desktop.
Save liquidz/1277976 to your computer and use it in GitHub Desktop.
def fizzbuzz(n:Int):IndexedSeq[String] = {
(1 to n).map(x => List(x % 15, x % 5, x % 3) match {
case List(0, _, _) => "FizzBuzz"
case List(_, 0, _) => "Buzz"
case List(_, _, 0) => "Fizz"
case _ => x + ""
})
}
println(fizzbuzz(15))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment