{"id":9598,"date":"2021-09-30T17:30:29","date_gmt":"2021-09-30T12:00:29","guid":{"rendered":"https:\/\/python-programs.com\/?p=9598"},"modified":"2021-11-22T18:33:32","modified_gmt":"2021-11-22T13:03:32","slug":"python-program-to-find-the-power-of-a-number-using-recursion","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-power-of-a-number-using-recursion\/","title":{"rendered":"Python Program to Find the Power of a Number Using Recursion"},"content":{"rendered":"

If you are new to Java and want to learn the java coding skills too fast. Try practicing the core java programs with the help of the Java basic programs list<\/a> available.<\/p>\n

Power of a number :<\/strong><\/p>\n

A number’s power (or exponent) aa represents the number of times xx must be multiplied by itself. It is written as a tiny number above and to the right of the base number.<\/p>\n

Recursion:<\/strong><\/p>\n

If you’re familiar with Python functions, you’ll know that it’s typical for one function to call another. It is also feasible for a function in Python to call itself! A recursive function calls itself, and the process of using a recursive function is known as recursion.<\/p>\n

Although it may appear strange for a function to call itself, many sorts of programming challenges are better stated recursively.<\/p>\n

Given a number N and the power of P. The aim is to develop a Python program that uses recursion to find the power of a number with the given base.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random base =8 \r\nEnter some random exponent value = 3<\/pre>\n

Output:<\/strong><\/p>\n

8 ^ 3 = 512<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random base =17\r\nEnter some random exponent value = 3<\/pre>\n

Output:<\/strong><\/p>\n

17 ^ 3 = 4913<\/pre>\n

Program to Find the Power of a Number Using Recursion in Python<\/h2>\n

Below are the ways to find the power of a number using the recursive approach in Python.<\/p>\n