title: Algorithm to check if a number if a perfect number
body: <p>I am looking for an algorithm to find if a given number is a perfect number. </p>
  
  <p>The most simple that comes to my mind is :</p>
  
  <ol>
  <li>Find all the factors of the number</li>
  <li>Get the prime factors [except the number itself, if it is prime] and add them up to check if it is a perfect number. </li>
  </ol>
  
  <p>Is there a better way to do this ?. 
  On searching, some Euclids work came up, but didnt find any good algorithm. Also this golfscript wasnt helpful: <a href="https://stackoverflow.com/questions/3472534/checking-whether-a-number-is-mathematically-a-perfect-number">https://stackoverflow.com/questions/3472534/checking-whether-a-number-is-mathematically-a-perfect-number</a> . </p>
  
  <p>The numbers etc can be cached etc in real world usage [which I dont know where perfect nos are used :)]<br>
  However, since this is being asked in interviews, I am assuming there should be a "derivable"  way of optimizing it.   </p>
  
  <p>Thanks !</p>