def factorial(n: Int) = (2 to n).foldLeft(1)(_ * _)