We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. Example: Input:…
完全数(Perfect number),又称完美数或完备数,是一些特殊的自然数.它所有的真因子(即除了自身以外的约数)的和(即因子函数),恰好等于它本身.如果一个数恰好等于它的因子之和,则称该数为"完全数". for ( int i = 2; i <= 1000; i++) { int sum = 0;//定义一个变量用于计算累加的因子之和,每次外层循环初始化 for (int j = 1; j < i/2+1; j++) { if (i % j == 0) { sum +…