diff --git a/src/Python/Problems001-050/Problem036.py b/src/Python/Problems001-050/Problem036.py index 4043417..de8b6d0 100644 --- a/src/Python/Problems001-050/Problem036.py +++ b/src/Python/Problems001-050/Problem036.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 08 Apr 2021 @@ -11,9 +11,11 @@ https://projecteuler.net/problem=36 from utils import timeit + def is_palidrome(num): return str(num) == str(num)[::-1] + @timeit("Problem 36") def compute(): """ @@ -23,13 +25,14 @@ def compute(): Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. """ + ans = 0 for i in range(1, 1_000_001, 2): - if is_palidrome(i) and is_palidrome(bin(i)[2:]): + if is_palidrome(i) and is_palidrome(bin(i)[2:]): ans += i + return ans if __name__ == "__main__": - - print(f"Result for Problem 36: {compute()}") \ No newline at end of file + print(f"Result for Problem 36 is {compute()}")