fork download
  1. object Main extends App {
  2. def fizzBuzz(n: Int): String = {
  3. val str = "fizz" * (1 - n % 3) + "buzz" * (1 - n % 5)
  4. if (str != "")
  5. if (n % 15 == 0) str.toUpperCase
  6. else str
  7. else n.toString
  8. }
  9. for(i <- 1 to 50) print(fizzBuzz(i))
  10. }
Success #stdin #stdout 0.4s 382016KB
stdin
Standard input is empty
stdout
12fizz4buzzfizz78fizzbuzz11fizz1314FIZZBUZZ1617fizz19buzzfizz2223fizzbuzz26fizz2829FIZZBUZZ3132fizz34buzzfizz3738fizzbuzz41fizz4344FIZZBUZZ4647fizz49buzz