Skip to content

Instantly share code, notes, and snippets.

@splacentino
Last active August 29, 2015 14:12
Show Gist options
  • Save splacentino/9a9a4cc5a6974a8776c3 to your computer and use it in GitHub Desktop.
Save splacentino/9a9a4cc5a6974a8776c3 to your computer and use it in GitHub Desktop.
Object FizzBuzz extends App {
def fBuzz(n : Int) {
if (n > 0 && n <= 100) {
if (n % 15 == 0) println("FizzBuzz")
else if (n % 3 == 0) println("Fizz")
else if (n % 5 == 0) println("Buzz")
fBuzz(n + 1)
}
}
def fBuzzz(n: Int) {
if (n > 0 && n <= 100) {
(n % 3 == 0, n % 5 == 0) match {
case (true, true) => println("FizzBuzz")
case (true, _) => println("Fizz")
case (_, true) => println("Buzz")
case _ => println(n)
}
fBuzz(n + 1)
}
}
fBuzz(1)
fBuzzz(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment