Last active
August 29, 2015 14:12
-
-
Save splacentino/9a9a4cc5a6974a8776c3 to your computer and use it in GitHub Desktop.
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
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