%mathpiper,def="ProperDivisorsSum"

10 # ProperDivisorsSum(_n) <--
[
        Check(IsPositiveInteger(n), "Argument", "ProperDivisorsSum: argument must be positive integer");
        DivisorsSum(n)-n;
];

%/mathpiper



%mathpiper_docs,name="ProperDivisorsSum",categories="User Functions;Number Theory"
*CMD ProperDivisorsSum --- the sum of proper divisors
*STD 
*CALL
	ProperDivisorsSum(n)
*PARMS  

{n}     -- positive integer

*DESC

{ProperDivisorsSum} returns the sum of proper divisors, i.e. {ProperDivisors(n)-n},
since {n} is not counted.
{n} is prime if and only if {ProperDivisorsSum(n)==1}.

*E.G.
In> ProperDivisorsSum(180)
Result: 366;
In> ProperDivisorsSum(37)
Result: 1;


*SEE DivisorsSum, ProperDivisors, ProperDivisorsSum, Moebius
%/mathpiper_docs