{"id":9722,"date":"2021-09-30T17:30:54","date_gmt":"2021-09-30T12:00:54","guid":{"rendered":"https:\/\/python-programs.com\/?p=9722"},"modified":"2021-11-22T18:33:31","modified_gmt":"2021-11-22T13:03:31","slug":"python-program-to-find-the-product-of-two-numbers-using-recursion","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-product-of-two-numbers-using-recursion\/","title":{"rendered":"Python Program to Find the Product of two Numbers Using Recursion"},"content":{"rendered":"

Our website provided core java programs examples with output<\/a> aid beginners and expert coders to test their knowledge gap and learn accordingly.<\/p>\n

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

When a function calls itself and loops until it reaches the intended end state, this is referred to as recursion. It is based on the mathematics idea of recursive definitions, which define elements in a set in terms of other members in the set.<\/p>\n

Each recursive implementation contains a base case in which the desired state is reached, and a recursive case in which the desired state is not reached and the function enters another recursive phase.<\/p>\n

On each step, the behavior in the recursive situation before the recursive function call, the internal self-call, is repeated. Recursive structures are beneficial when a larger problem (the base case) can be solved by solving repeated subproblems (the recursive case) that incrementally advance the program to the base case.
\nIt behaves similarly to for and while loops, with the exception that recursion moves closer to the desired condition, whereas for loops run a defined number of times and while loops run until the condition is no longer met.<\/p>\n

In other words, recursion is declarative because you specify the desired state, whereas for\/while loops are iterative because you provide the number of repeats.<\/p>\n

Given two numbers the task is to find the product of the given two numbers using recursion in Python.<\/p>\n

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

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

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

given the first number = 27 \r\ngiven the second number = 19<\/pre>\n

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

The product of the given numbers 27 and 19 is 27 * 19 = 513<\/pre>\n

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

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

given the first number = 23\r\ngiven the second number = 38<\/pre>\n

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

The product of the given numbers 23 and 38 is 23 * 38 = 874<\/pre>\n

Program to Find the Product of two Numbers Using Recursion<\/h2>\n

Below are the ways to Find the Product of two Numbers using the recursive approach in Python:<\/strong><\/p>\n