Created
December 26, 2022 13:49
-
-
Save SMoni/0273962c9e11c7f23716a8223f5849f5 to your computer and use it in GitHub Desktop.
What will this method do...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_magic(decimal_num:int): | |
if decimal_num < 2: | |
return decimal_num | |
result = 0 | |
square_num = 2 | |
while square_num < decimal_num: | |
square_num *= 2 | |
while square_num > .5: | |
result *= 10 | |
if decimal_num >= square_num: | |
decimal_num -= square_num | |
result += 1 | |
square_num /= 2 | |
return result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment