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

Exercise - Recursion: Input: 1234567 Output: 7654321

The document discusses using recursion to solve various problems including calculating powers, reversing sequences, factorials, Fibonacci numbers, printing patterns, converting numbers to binary, and implementing binary search. It provides examples of defining recursive functions to calculate powers without using loops, multiplication, or built-in math functions, as well as examples of recursively printing sequences in reverse order and calculating factorials and Fibonacci numbers.
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)
38 views1 page

Exercise - Recursion: Input: 1234567 Output: 7654321

The document discusses using recursion to solve various problems including calculating powers, reversing sequences, factorials, Fibonacci numbers, printing patterns, converting numbers to binary, and implementing binary search. It provides examples of defining recursive functions to calculate powers without using loops, multiplication, or built-in math functions, as well as examples of recursively printing sequences in reverse order and calculating factorials and Fibonacci numbers.
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
You are on page 1/ 1

Exercise – Recursion

Given a positive real number a and a non-negative integer n. Calculate an without using
loops, ** operator or the built in function math.pow(). Instead, use recursion and the
relation an=a⋅an-1. Print the result. Form the function power (a, n).
Given a sequence of integers. Print the sequence in reverse order using recursion.
Input: 1234567 Output: 7654321
Compute the factorial of a number using recursion
Given a non-negative integer n, print the nth Fibonacci number. Do this by writing a
function fib(n) which takes the non-negative integer n and returns the nth Fibonacci number.
Print following patterns using recursion.
* * * *****
* * ** ** ****
* ** *** *** ***
* *** **** **** **
* * *** ***** ***** *
Given an integer number. Convert it into its equivalent Binary number using recursion.
Implement Binary Search algorithm using the recursion.

You might also like