Finished 36, was really easy
This commit is contained in:
12
36/main.py
12
36/main.py
@@ -9,11 +9,21 @@ Find the sum of all numbers, less than one million, which are palindromic in bas
|
|||||||
def isPalindrome(n):
|
def isPalindrome(n):
|
||||||
return n == int(str(n)[::-1])
|
return n == int(str(n)[::-1])
|
||||||
|
|
||||||
|
def makeBinary(n):
|
||||||
|
return int(bin(n)[2:])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Hello this is Patrick")
|
print("Hello this is Patrick")
|
||||||
|
|
||||||
for n in range(1000000):
|
print(makeBinary(8))
|
||||||
|
|
||||||
|
summand = 0
|
||||||
|
|
||||||
|
for n in range(1000000):
|
||||||
|
if isPalindrome(n) and isPalindrome(makeBinary(n)):
|
||||||
|
summand += n
|
||||||
|
|
||||||
|
print(summand)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user