day1/exercise/even_perfect_4.py
changeset 64 333092b68926
child 430 f97ecb4e04a9
equal deleted inserted replaced
63:f5eac04a00fe 64:333092b68926
       
     1 def is_perfect_square(n):
       
     2     i = 1
       
     3     while i * i < n:
       
     4         i += 1
       
     5     return i * i == n
       
     6 
       
     7 def all_digits_even(n):
       
     8     if n < 0: n = -n
       
     9     while n > 0:
       
    10         if n % 2 == 1:
       
    11             return False
       
    12         n /= 10
       
    13     return True
       
    14 
       
    15 for i in range(2222, 8888):
       
    16     if all_digits_even(i) and is_perfect_square(i):
       
    17         print i