VOOZH about

URL: https://www.geeksforgeeks.org/matlab/factorial-in-matlab/

⇱ Factorial in MATLAB - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Factorial in MATLAB

Last Updated : 28 Apr, 2025

MATLAB is a high-performance language that is used for matrix manipulation, performing technical computations, graph plottings, etc. It stands for Matrix Laboratory. In this article, we'll be calculating the factorial of a number n using MATLAB's built-in function 'factorial(number)'.

Factorial:

The factorial of a non-negative integer is the multiplication of all positive integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720. The factorial of a number n is represented as n!

0! = 1

1! = 1

Now suppose we want to find a Factorial of 6. 

Example 1:

Output:

👁 Image
output

Now take another example to find a factorial of 22.

Example 2:

Output:

👁 Image
 

In the given below example, we find the factorial of matrix elements.

Example 3:

Output:

👁 Image
 
Comment