Created
March 6, 2016 14:24
-
-
Save miguelsaddress/db91ac43ed447763ceb4 to your computer and use it in GitHub Desktop.
Scala FizzBuzz implementation
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
import scala.util.Try | |
object FizzBuzz { | |
def main(args: Array[String]): Unit = { | |
val iterations = Try(args(0).toInt).getOrElse(0) | |
(1 to iterations).foreach {i => | |
if (i % 15 == 0) println(s"$i - FizzBuzz") | |
else if (i % 3 == 0) println(s"$i - Fizz") | |
else if (i % 5 == 0) println(s"$i - Buzz") | |
else println(s"$i") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment