diff --git a/Bit-manipulationTechniques/DecimalToBinary/main.py b/Bit-manipulationTechniques/DecimalToBinary/main.py new file mode 100644 index 0000000..9bc62f7 --- /dev/null +++ b/Bit-manipulationTechniques/DecimalToBinary/main.py @@ -0,0 +1,19 @@ +def convert_to_binary(n: int): + ans = 0 + exp = 1 + + while n > 0: + ans += (n % 2) * exp + exp *= 10 + n = n // 2 + + return ans + + +def main(): + n = int(input()) + print(convert_to_binary(n)) + + +if __name__ == "__main__": + main()