Renamed all folders

This commit is contained in:
2021-04-16 16:58:48 +02:00
parent dbc6cfef05
commit 197b3eea8a
62 changed files with 0 additions and 0 deletions

29
036/main.py Normal file
View File

@@ -0,0 +1,29 @@
'''
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
'''
def isPalindrome(n):
return n == int(str(n)[::-1])
def makeBinary(n):
return int(bin(n)[2:])
def main():
print("Hello this is Patrick")
print(makeBinary(8))
summand = 0
for n in range(1000000):
if isPalindrome(n) and isPalindrome(makeBinary(n)):
summand += n
print(summand)
if __name__ == "__main__":
main()