Recursion

[Set – 1]

1. Write a recursive function that accepts an integer argument and returns the factorial. Solution

2. Write a recursive function that accepts two numbers as its argument and returns its power. Solution

3. Write a recursive function that accepts a number as its argument and returns the sum of digits. Solution

4. Write a program that reads two integers from keyboard and calculate the greatest common divisor (gcd) using recursive function. Solution

5. Write a recursive function that accepts an integer argument in n. This function returns the nth Fibonacci number. Call the function to print fibonacci sequences. Solution

6. Write a recursive function that accepts a decimal integer and display its binary equivalent. Solution

7. Write a recursive function that calculate sum of first n natural numbers. Solution

8. Write a Recursive function in python BinarySearch(Arr, L, R, X) to search the given element X to be searched from the List Arr having R elements, where L represents lower bound and R represents the upper bound. Solution