Here’s a one-liner in JavaScript to find the factorial of a number using recursion:
const factorial = (num) => (num < 2 ? 1 : num * factorial(num - 1));
This function takes a number as input and recursively calculates its factorial by multiplying it with the factorial of the number one less than it until it reaches 1. If the input number is less than 2, the function returns 1.
Thank you for reading, and let’s have conversation with each other
Thank you for reading my article. Let’s have conversation on Twitter and LinkedIn by connecting.