From 0b9d413064b4a56ee36be85da3caf005c700c5af Mon Sep 17 00:00:00 2001 From: the-rebooted-coder2 <91176276+the-rebooted-coder2@users.noreply.github.com> Date: Fri, 1 Oct 2021 16:16:28 +0530 Subject: [PATCH] Create decimaltoBinary.py --- decimaltoBinary.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 decimaltoBinary.py diff --git a/decimaltoBinary.py b/decimaltoBinary.py new file mode 100644 index 0000000..13469e0 --- /dev/null +++ b/decimaltoBinary.py @@ -0,0 +1,11 @@ +# Function to print binary number using recursion +def convertToBinary(n): + if n > 1: + convertToBinary(n//2) + print(n % 2,end = '') + +# decimal number +dec = 34 + +convertToBinary(dec) +print()