Nov
14
Scala program to find Factorial of a given number
Hey there! Welcome to ClearUrDoubt.com. In this post, we will look at a Scala program to find Factorial of a given number using Linear Recursion. Let’s look at the program:
1 2 3 4 5 6 7 8 9 10 |
package com.clearurdoubt object Factorial extends App { def factorial(n: Int) : Int = { if (n == 0) 1 else n * factorial(n-1) // Linear Recursion } println(factorial(10)) } |
Output: Currently this program uses Linear Recursion for finding Read more