We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52d62ac commit 8808751Copy full SHA for 8808751
Decimal value to Binary value
@@ -0,0 +1,9 @@
1
+def decimal_to_binary(n):
2
+ if n > 1:
3
+ decimal_to_binary(n // 2) # Recursive call
4
+ print(n % 2, end="")
5
+
6
+# Example usage:
7
+decimal_number = 10 # Replace with the decimal number you want to convert
8
+print(f"The binary equivalent of {decimal_number} is: ", end="")
9
+decimal_to_binary(decimal_number)
0 commit comments