Skip to content

Instantly share code, notes, and snippets.

@joshrotenberg
Created October 31, 2012 21:55
Show Gist options
  • Select an option

  • Save joshrotenberg/3990186 to your computer and use it in GitHub Desktop.

Select an option

Save joshrotenberg/3990186 to your computer and use it in GitHub Desktop.
FizzBuzz in Scala
object FizzBuzz {
def main(args: Array[String]) {
1.to(100).foreach( (i:Int) => (i % 3, i % 5) match {
case (0,0) => println("FizzBuzz")
case (0, _) => println("Fizz")
case (_, 0) => println("Buzz")
case _ => println(i)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment