再问一道,都是我的作业题
Greek mathematicians took special interest in integers that are equal to the sum of their proper divisors (aproper divisor of an integer nis any divisor strictly less than nitself.) They called such numbers perfect
numbers. For example, 6is a perfect number because it is the sum of 1, 2, and 3, which are the
integers less than 6that divide evenly into 6. Similarly, 28is a perfect number because its proper divisors
are 1, 2, 4, 7, and 14.
Write a predicate function IsPerfectwhich takes an integer nas its only argument and returns TRUEif
and only if nis perfect, and FALSEotherwise. (Sadly enough, this problem has no fast food references.)
/*
*Function:IsPerfect
*if(IsPerfect(number)){
*-------------------
*IsPerfectreturnsTRUEifandonlyifthethespecifiedintegerisa
*perfectinteger.Anumberisperfectifandonlyifitequalsthesum
*ofitsproperdivisors.Thespecifiedintegerisassumedtobe
*positive,andnoerrorcheckingisperformed.
*/
boolIsPerfect(intn)