0% found this document useful (0 votes)
7 views14 pages

Recursion

The document discusses the concept of recursion in programming, providing examples such as calculating factorials, powers, and checking if a number is a power of two. It outlines the structure of recursive functions, including the known and unknown parts, and emphasizes breaking problems into smaller parts. Additionally, it mentions summing digits and generating Fibonacci series as further applications of recursion.

Uploaded by

pdebnath2430496
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)
7 views14 pages

Recursion

The document discusses the concept of recursion in programming, providing examples such as calculating factorials, powers, and checking if a number is a power of two. It outlines the structure of recursive functions, including the known and unknown parts, and emphasizes breaking problems into smaller parts. Additionally, it mentions summing digits and generating Fibonacci series as further applications of recursion.

Uploaded by

pdebnath2430496
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

S S S S S S S S S S S S S

T T T T T T T T T T T T T
R R R R R R R R R R R R R
U U U U U U U U U U U U U
C C C C C C C C C C C C C
T T T T T T T T T T T T T
U U U U U U U U U U U U U
R R R R R R R R R R R R R
D A T AU T R U C T
A D T A S C R U C T U
T A D A S T T U C T U R
D A T A S T R U C T U R E
A S A T T R UR T U
&
R E
T T A L GO R I T H M
S A R UC E U R E
A R T S UC T R E
S U R T C T U E
Recursion
Recursion
Recursion

Recursion

Known Part Unknown Part

If ()
else{}
Return
Break it in
Smaller Part

Call the
function again
Recursion
▪ Find the Factorial of n using recursion.. Recursion

Known Part Unknown Part

If () else{}
Return Break it in
Smaller Part

Call the
function again
Recursion
❑ Calculate Power (𝑥 𝑛 ) Using Recursion Recursion

Known Part Unknown Part

If () else{}
Return Break it in
Smaller Part

Call the
function again
Recursion
❑ Check Power of Two
[Ex: 32-> Yes, Power of Two ; 18 -> No, not a power of two.]
Recursion
❑ Sum of Digits (Recursive)
[ex: 760 = 7+6+0=13]
Recursion

❑ Sum of First N Odd Numbers


Recursion

❑ Sum of First N Even Numbers


Recursion

❑ Find Nth terms of Fibonacci series


Alhamdulillah
Thank You

You might also like