Created
August 1, 2011 21:30
-
-
Save stevenwilkin/1119050 to your computer and use it in GitHub Desktop.
FizzBuzz implemented in Scala
This file contains 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
// 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