Basic Recursion Practice Problem.

Anik Dey
2 min readApr 28, 2021
  1. Write a program to print first 50 natural numbers using recursion.
  2. Write a recursive function that takes a number and returns the sum of all the numbers from zero to that number.
  3. Write a program to count the digits of a given number using recursion.
  4. Write a recursive function that takes a number as an input and returns the factorial of that number.
  5. Write a program to Print Fibonacci Series using recursion.
  6. Write a recursive function that takes a number ’n’ and returns the nth number of the Fibonacci number.
  7. Write a recursive function that takes a list of numbers as an input and returns the product of all the numbers in the list.
  8. Write a function that takes a string and returns if the string is a palindrome.
  9. Write a recursive function that takes a string and reverse the string.
  10. Write a recursive function that takes an array of words and returns an array that contains all the words capitalised. Input: [‘foo’, ‘bar’, ‘world’, ‘hello’], Output: [‘FOO’, ‘BAR’, ‘WORLD’, ‘HELLO’]
  11. Write a program to print the array elements using recursion.
  12. Write a program to get the largest element of an array using recursion.
  13. Write a program to find GCD of two numbers using recursion.
  14. Write a program to convert a decimal number to binary using recursion.
  15. Write a program to check a number is a prime number or not using recursion.
  16. Write a program to find the LCM of two numbers using recursion.
  17. Write a program to print even or odd numbers in given range using recursion.
  18. Write a program to print even or odd numbers in given range using recursion.
  19. Write a program to calculate the power of any number using recursion. (2⁶ = 64)
  20. Write a program to copy One string to another using recursion.
  21. Write a program to find the first capital letter in a string using recursion. //The first capital letter appears in the string testString is S.
  22. Write a program for binary search using recursion.
  23. Write a recursive function to reverse the words in a string, i.e., ”cat is running” becomes ”running is cat”.

--

--