**Article by:** Manish Methani

**Last Updated:** September 27, 2021 at 10:04am IST

Factorial of a given number is defined as the product of a given number with its previous number till that number reaches 1. In mathematical representation, factorial is represented by !

Factorial of 5! is

5*4*3*2*1 = 120

#include int main() { int number = 5,i; long int factorial; factorial = 1; for(i = number; i >= 1; i--) { factorial = factorial * i; printf(" Factorial of %d is = %ld", number, factorial); return 0; }

Factorial of 5 is = 120

#include long int factorial(int n) { int i; long int factorial = 1; if(n==1) return factorial; for(i = n; i >= 1;i--) { factorial = factorial * i; return factorial; } } int main() { int number = 5; printf(" Factorial of %d is = %ld",number,factorial(number)); return 0; }

Factorial of 5 is = 120

#include long int factorial(int n) { if(n==1) return 1; return n*factorial(n-1); } int main() { int number = 5; printf("Factorial of %d is = %ld",number,factorial(number)); return 0; }

Factorial of 5 is = 120

10 OS Interview Questions you must know in 2024

10 Angular Interview Questions you must know in 2024

10 Javascript Interview Questions you must know in 2024

Top 10 DSA Interview Questions You should not miss

Top 10 Web Development Interview Questions

Introduction to Next.js

Altina Schinasi: Celebrating the Visionary Designer of Cat-Eye Frames | Google Doodle Tribute

Best Niche for Blogging in USA: A Comprehensive Guide

18 Must-Do Activities for Computer Science Students in College

13 Essential Things Solopreneurs need to know in 2024

25 Practical ways to earn money online

The Power of Gratitude - A Journey to Personal Growth

Top 5 Technology Trends That Are Shaping Our Future

5 Books You Need to Read Right Now

How to answer tell me about yourself?

What Angular feature transforms data before displaying it in the view?

Which widget is used in Flutter to create a button?

6 Mobile App Ideas That You Can Start in 2024

Flutter Widget Showdown: Exploring the Developers Favorite for Layouts!

Mobile App

For Engineers.

Mock Tests.

Test your C Programming skills with this comprehensive mock test on C Programming.

Take TestSolve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take TestSolve most asked GATE Questions in Operating Systems and test your Gate Score.

Take TestThis is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take TestSolve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take Test