Example 1 : Find nth Factorial

TopicDifficultyCompanies
Recursion and Divide & Conquer Approach
EASY

Write a program to find the factorial of a given number n.

Problem Note

  • n is a non-negative integer.
  • Factorial of a non-negative integer n is multiplication of all integers smaller than or equal to n

Example

Input: n = 6
Output: 720
Explanation: Factorial of 6 is 6*5*4*3*2*1 which is 720.

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.