2

C++ Program to Find Factorial of a Number

 2 years ago
source link: https://www.geeksforgeeks.org/videos/c-program-to-find-factorial-of-a-number/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

C++ Program to Find Factorial of a Number

C++ Program to Find Factorial of a Number
Hey everybody. Welcome to Geeks Geeks.
  • 18/05/2022

In this video, we will see a C++ program to find the Factorial of a Number. Basically, the Factorial of a non-negative integer is the multiplication of all integers smaller than or equal to n. For example: Factorial of 6 is 6*5*4*3*2*1 which is 720. Factorial of 5 is 5*4*3*2*1 which is 120.

Here we see two different method for calculate factorial of any integer number. 1. Recursive Solution: Factorial can be calculated using following recursive formula. n! = n * (n-1)! n! = 1 if n = 0 or n = 1

2. Iterative Solution: Factorial can also be calculated iteratively as recursion can be costly for large numbers. Here we have see the iterative approach using both for and while loop for finding factorial.

Program to Find Factorial: https://www.geeksforgeeks.org/program-for-factorial-of-a-number/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK