<> 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
©2019-2020 Toolsou All rights reserved,
Android Using wechat in H5 Payment result refresh during payment shock !!C++ Can make a sound ! Basic operation of single linked list C Language explanation Java Implement an epidemic number management system 2021 year 11 World programming language ranking linux upper mysql Invalid command _linux lower mysql The command is useless Java project : Campus dormitory management system (java+jsp+javaweb+mysql+ajax) Wechat applet development project directory linux ubuntu Which version ,Ubuntu Which version is the best ?python Code painting cherry blossoms - How to use Python Draw a beautiful cherry blossom