0% found this document useful (0 votes)
4 views1 page

Recursive Fun C

A recursive function is one that calls itself, similar to the concept in mathematics. An example is the factorial function, defined as n! = n * (n-1)!, with a base case of 0! = 1. The document also provides a Python implementation of the factorial function using recursion.

Uploaded by

skillsmatters432
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Recursive Fun C

A recursive function is one that calls itself, similar to the concept in mathematics. An example is the factorial function, defined as n! = n * (n-1)!, with a base case of 0! = 1. The document also provides a Python implementation of the factorial function using recursion.

Uploaded by

skillsmatters432
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Recursive Function

• A function calling itself is called recursive function


• It is same as the recursive function in mathematics
• A factorial is de ned in terms of factorial only ,therefore it is called recursive function

Ex : n ! = 1 * 2 * 3 * 4 * 5 ….. * n

5! = 5 * 4 * 3 * 2 * 1

5! = 5 * 4!

n! = n * ( n -1)

• In maths recursive function is also de ne as

fact( n ) = { 1 if n=0

n * fact(n-1) if n>0

• In python we can write the same thing as


Ex:

def fact ( n ) :

If n == 0 :

return 1

else :

Return n * fact ( n-1)

Output :
fi
fi

You might also like