We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 9: Recursion 3
Day 9: Recursion 3
Sort by
recency
|
1123 Discussions
|
Please Login in order to post a comment
def factorial(n): if n == 0 or n == 1: return n else: return n * factorial(n - 1)
In C#
C++
one liner w/ ternary operator:
public static int factorial(int n) { return n == 1 ? 1 : n * factorial(n-1); }
JAVA