Program of built-in factorial function, MATLAB in Mathematics

Program of built-in factorial function:

Calling this function yields similar result as the built-in factorial function:

>> fact(5)

ans =

  120

>> factorial(5)

ans =

  120

The recursive factorial function is a very common illustration of a recursive function. It is somewhat of a lame illustration, though, as recursion is not essential to find a factorial; a for loop can be just used as well in the programming (or, obviously, the built-in function in MATLAB).

 

Posted Date: 10/22/2012 1:32:35 AM | Location : United States







Related Discussions:- Program of built-in factorial function, Assignment Help, Ask Question on Program of built-in factorial function, Get Answer, Expert's Help, Program of built-in factorial function Discussions

Write discussion on Program of built-in factorial function
Your posts are moderated
Related Questions
Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Example of Recursive functions: This definition is recursive as a factorial is defined in terms of the other factorial. There are two parts to any recursive definition: the co

Function isreal - complex numbers: The function isreal returns 1 for logical true when there is no imaginary part of the argument, or 0 for false when the argument does have a

Illustration of Labels and prompts: The program below prompts the user for endpoints (x1, y1) and (x2, y2) of a line segment, and computes the midpoint of the line segment, th

Print an imaginary number: To print an imaginary number, the function disp will show both parts automatically: >> disp(z1)    4.0000 + 2.0000i The function fprint

This project requires you to use the ideas of Chapter 25 regarding maximization of a function. Here we assume that evolution has acted to generate highly efficient foragers. By hig

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

Strcat function - Concatenation : The strcat function, though, will eliminate the trailing blanks from strings before concatenating. Note that in these illustrations, the trail

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal