day1/exercise/arms.py
changeset 355 6af6441034f9
equal deleted inserted replaced
354:5dc6c3673f9d 355:6af6441034f9
       
     1 # Armstrong Numbers
       
     2 
       
     3 for n in range(100, 1000):
       
     4 #    s = str(n)
       
     5 #    a, b, c = int(s[0]), int(s[1]), int(s[2])
       
     6 #    if a * a * a + b * b * b + c * c * c == n:
       
     7 #       print n
       
     8 #   sum, copy = 0, n    
       
     9 #   while copy > 0:
       
    10 #       sum += (copy % 10) ** 3
       
    11 #       copy /= 10
       
    12 #   if sum == n:
       
    13 #      print n
       
    14     u = n % 10
       
    15     h = n / 100
       
    16     t = (n/10) % 10
       
    17     if h ** 3 + t ** 3 + u ** 3 == N:
       
    18         print n