<> perfect number ：

Perfect number （Perfect number）, Also known as perfect number or complete number , Are some special natural numbers . All its true factors （ That is, divisor other than itself ） Sum of （ Factor function ）, Exactly equal to itself .

use C Language output 1-1000 Perfections within , Shape such as 6 = 1+2+3

source code
#include<stdio.h> // Print out 1-1000 All completions in , Format is : 6=1+2+3 //1. Judge whether a number is complete bool
IsPerfect(int num) { int tmp=0;// Save the sum of all factors for (int i = 1; i < num; i++) { if (
num% i == 0)// If num Can be i to be divisible by ,i namely num A factor of { tmp += i;// Sum of all factors } } return tmp == num;
// True or false of the return value tmp and num Equality decision , Equal return true, Unequal return false } //2. Write a print function like 6=1+2+3 void Print(int
num) { printf("%d = 1",num); for (int i = 2; i < num; i++)// Circular lookup factor { if (num %
i== 0)// If it is a factor, print it { printf("+ %d",i); } } printf("\n"); } int main() { for (int i
= 1; i < 1000; i++) { if (IsPerfect(i) == true)// find 1-1000 Perfections within { Print(i);
// If it is completed, print it } } return 0; }
Operation results

Try to get stronger Day2

“ I am a little crab , One day when I was walking, two pliers fell off , I'll go to the doctor , The doctor asked me what happened , I said I had no pliers ” If you see it, please smile
Today should be as happy as yesterday But lovely love every day Wait for the flowers to bloom in spring

——End

Technology
Daily Recommendation
views 2