title: Sum of amicable numbers -- Euler task 21
body: <pre><code>def f(a):
      sum=0
      for i in range(1,a):
          if(a%i==0):
              sum=sum+i
  
      return sum
  
  sum2=0
  for i in range(1,10000):
      q=f(i)
      if f(q)==i:
          sum2=sum2+i
  
  print(f(sum2))
  </code></pre>
  
  <p>I wrote this for <a href="https://projecteuler.net/problem=21" rel="nofollow noreferrer">project euler problem 21</a> and its gave to me 64436.
  Unfornutely I couldnt find my mistake by myself. Where is my mistake?   </p>
  
  <blockquote>
    <p>Let d(n) be defined as the sum of proper divisors of n (numbers less
    than n which divide evenly into n). If d(a) = b and d(b) = a, where a
    ≠ b, then a and b are an amicable pair and each of a and b are called
    amicable numbers.</p>
    
    <p>For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20,
    22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284
    are 1, 2, 4, 71 and 142; so d(284) = 220.</p>
    
    <p>Evaluate the sum of all the amicable numbers under 10000.</p>
  </blockquote>