Got a working algorithm for computing perfect numbers