{"id":19091,"date":"2021-08-29T15:13:29","date_gmt":"2021-08-29T09:43:29","guid":{"rendered":"https:\/\/python-programs.com\/?p=19091"},"modified":"2021-11-22T18:37:09","modified_gmt":"2021-11-22T13:07:09","slug":"python-program-to-convert-decimal-number-to-binary-string-using-recursion","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-convert-decimal-number-to-binary-string-using-recursion\/","title":{"rendered":"Python Program to Convert Decimal Number to Binary String using Recursion"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Convert Binary to Decimal using Recursion<\/a>
\nRecursion:<\/strong><\/p>\n

Recursion is the process by which a function calls itself directly or indirectly, and the associated function is known as a recursive function. Certain issues can be addressed fairly easily using a recursive approach. Towers of Hanoi (TOH), Inorder \/Preorder\/Postorder Tree Traversals, DFS of Graph, and other analogous issues are examples.<\/p>\n

Binary Code:<\/strong><\/p>\n

As previously stated, Binary Code is a Base-2 representation of a number. In Binary, all numbers are represented by simply two symbols: 0 and 1. Binary (also known as base-2) is a numerical system with only two digits: 0 and 1.<\/p>\n

Given a binary string, the task is to convert the given decimal number to a binary string using recursion in Python.<\/p>\n

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

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

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

Given binary number = 153<\/pre>\n

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

The decimal Equivalent of the given binary number { 153 } is : 10011001<\/pre>\n

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

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

Given binary number = 408<\/pre>\n

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

The decimal Equivalent of the given binary number { 408 } is : 110011000<\/pre>\n

Program to Convert Decimal Number to Binary String using Recursion in Python<\/h2>\n

Below are the ways to convert the given decimal number to a binary string using recursion in Python:<\/p>\n