Skip to content

Instantly share code, notes, and snippets.

@tyru
Created April 6, 2009 11:45
Show Gist options
  • Select an option

  • Save tyru/90725 to your computer and use it in GitHub Desktop.

Select an option

Save tyru/90725 to your computer and use it in GitHub Desktop.
object Main {
def main(args:Array[String]) = {
val DEFAULT = 100
val end:Int = {
if (args.isEmpty)
DEFAULT
else
try {
Integer.parseInt(args(0))
} catch {
case e:java.lang.NumberFormatException => {
Console.err.println("warning: 不正な値が渡されました: " + args(0))
Thread.sleep(1000)
DEFAULT
}
}
}
(1 to end).foreach(n =>
println(
if (n % 15 == 0)
"FizzBuzz"
else if (n % 5 == 0)
"Buzz"
else if (n % 3 == 0)
"Fizz"
else
n
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment