From ebc5a43269c6728edf73c524522cef5170178712 Mon Sep 17 00:00:00 2001 From: Midhun Date: Fri, 17 Jun 2022 00:44:02 +0530 Subject: [PATCH] algorithm to convert decimal to binary --- algorithms/math/decimal_to_binary.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 algorithms/math/decimal_to_binary.py diff --git a/algorithms/math/decimal_to_binary.py b/algorithms/math/decimal_to_binary.py new file mode 100644 index 0000000..9739363 --- /dev/null +++ b/algorithms/math/decimal_to_binary.py @@ -0,0 +1,12 @@ +"""converting decimal to binary. + +@author Midhun Nair +""" + +def decimal_to_bonary(number:int): + if number >= 1: + decimal_to_bonary(number // 2) + print(number % 2, end = "") + +if __name__ == "__main__": + decimal_to_bonary(5) \ No newline at end of file