Factorial in MATLAB Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Matlab % MATLAB code for find factorial ans = factorial(6); disp(ans); Output: outputNow take another example to find a factorial of 22. Example 2: Matlab % MATLAB code for find factorial format long; ans = factorial(22); disp(ans); Output: In the given below example, we find the factorial of matrix elements. Example 3: Matlab % MATLAB code to find the factorial of matrix elements. % Input Matrix input = [[1,5,8];[4,6,0]]; disp(input); % Output Matrix output = factorial(input); disp(output); Output: Comment More infoAdvertise with us Next Article MATLAB Commands A akashish__ Follow Improve Article Tags : Software Engineering Technical Scripter 2022 MATLAB-Maths Similar Reads MATLAB Commands MATLAB is an interactive multi-programming language and numeric computing environment developed by MathWorks. MATLAB provides the Commands that will be used when the user wants to interact with any application using the command line interface. Following are the lists of commands used in MATLAB. Com 3 min read Simple GUI Calculator in MATLAB MATLAB is a powerful programming language that makes working with different mathematical equations easier. It is widely preferred by engineers and scientists. In this article, we will see, how to build a GUI-based simple calculator in MATLAB, which will take input and will return a value. So let's g 3 min read Text Formatting in MATLAB In the real-world data can be any form. This data may be in binary, numeric, text, array, and so on. And this data can be converted into text. In Matlab, the text can be formatted using a formatting operator along with formatting functions such as sprintf, numstr, fprintf, compose. These functions/o 4 min read Local Functions in MATLAB Functions in any programming language are some blocks of code, which could be reused whenever required, by just calling the name. It reduces so much of human effort and also rewriting of the same code, and makes the entire code big. Declaring a function:Before moving forward let's see how actually t 2 min read Curve Fitting in MATLAB Curve fitting is the method of finding a suitable equation for a given data or one could say finding a pattern in some random data. The goal of this article is to learn curve fitting using MATLAB thus, it is expected that the reader has knowledge of curve fitting in mathematical terms. Step of Curv 2 min read MATLAB - Algebra Algebra is all about the study of mathematical symbols and rules for manipulating these symbols. Here variables are used to store/represent quantities. In MATLAB, there are certain in-built methods to solve algebra equations. Roots of equations, solving for x, simplifying an expression are some thin 4 min read Like