Factorial

Report a typo

Enter the numeric output of the factorial function call.

scala> def factorial(x: Int): Int = if x == 1 then 1 else x * factorial(x - 1)
factorial: (x: Int)Int
scala> factorial(10)
val res1: Int = ???
Enter a number
___

Create a free account to access the full topic