Skip to content

Instantly share code, notes, and snippets.

@stevenwilkin
Created August 1, 2011 21:30
Show Gist options
  • Save stevenwilkin/1119050 to your computer and use it in GitHub Desktop.
Save stevenwilkin/1119050 to your computer and use it in GitHub Desktop.
FizzBuzz implemented in Scala
// http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
//
// run with `scala fizz_buzz.scala`
for(i <- 1 until 101) {
if(((i % 3) == 0) && ((i %5) == 0)) {
println("FizzBuzz")
} else if((i % 3) == 0) {
println("Fizz")
} else if((i % 5) == 0) {
println("Buzz")
} else {
println(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment