A pseudoperfect number, sometimes also called a semiperfect number (Benkoski 1972, Butske et al. 1999), is a positive integer such as which is the sum of some (or all) of its proper divisors,

A pseudoperfect number which is the sum of all its proper divisors is called a perfect number. The first few pseudoperfect numbers are 6, 12, 18, 20, 24, 28, 30, 36, 40, ...

logic which i thought for this program was to add all its factors and then keep subtracting each individual factors from the sum.....and then if the difference is equal to the number it is a pseudoperfect

but this doesn't work with all the numbers for eg:

20=(1+2+4+5+10)-2 (pseudo perfect)

30=(1+2+3+5+6+10+15)=42 and thus doesn't satisfy gthe logic

pls help with this