当前位置:网站首页>C language classic exercises to write a program to find all the perfects within 1000.
C language classic exercises to write a program to find all the perfects within 1000.
2022-07-24 04:22:00 【Serendipity_-】
Write a program , find 1000 All of the completions within , The so-called perfect number is a number exactly equal to the sum of its factors ,
for example 6=1+2+3,6 It's a perfect number .
// Write a program , find 1000 All of the completions within , The so-called perfect number is a number exactly equal to the sum of its factors ,
// for example 6=1+2+3,6 It's a perfect number .
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a, b, sum;
for (a = 2; a < 1000; a++)
{
sum = 0;
for (b = 1; b < a; b++)
{
if (a % b == 0)
{
sum += b;
}
}
if (sum == a)
printf("%d ", a);
}
return 0;
}
The operation result is as shown in the figure :
边栏推荐
- MySQL service 1 master 2 slave, master master, MHA configuration detailed steps
- Embedded system transplantation [6] - uboot source code structure
- ECB interface is also mdsemodet in essence
- Codeforces Round #809 (Div. 2) A - D1
- Function application of 4G transmission module
- conda 常用命令
- Pat grade a 1041 be unique
- Particle Designer:粒子效果制作器,生成plist文件并在工程中正常使用
- What new opportunities exist in the short video local life section?
- Combinatorial number (number of prime factors of factorials, calculation of combinatorial number)
猜你喜欢

Alibaba Taobao Department interview question: how does redis realize inventory deduction and prevent oversold?

Design and implementation of data analysis platform for intelligent commerce

Svg image color modification is not fancy

adobe PR2022 没有开放式字幕怎么办?

postgresql源码学习(32)—— 检查点④-核心函数CreateCheckPoint

PMIX ERROR: ERROR in file gds_ ds12_ lock_ pthread.c

What is the real HTAP? (2) Challenge article

Post it notes --46{hbuildx connect to night God simulator}

【新手向 】手把手开发一个易于扩展的 Tabs 组件

(5) Digital electricity formula simplification method
随机推荐
[C language] program environment and preprocessing operation
【C语言】程序环境和预处理操作
Redis sentinel mode, master node check script
Sqlserver backup restore
Page Jump and redirection in flask framework
Combinatorial number (number of prime factors of factorials, calculation of combinatorial number)
Avoid mistakes, common appium related problems and Solutions
Design and implementation of data analysis platform for intelligent commerce
What if the references in the word sent by others are {} in such a garbled format
6-15 vulnerability exploitation SMB rce remote command execution
Game improvement of smart people: Lesson 2 of Chapter 3: number of factors
[JS] save the string as a file to the local (.Txt,.Json,.Md...)
mongo从开始到安装以及遇到的问题
MOS摄像化、数字化”包含指定(contro.熟练的
Pat grade a 1041 be unique
Parallel technology of Oracle
D2DEngine食用教程(3)———将渲染目标导出为图像文件
Mongo from start to installation and problems encountered
Live classroom system 04 create service module
[translation] chaos mesh moved to CNCF incubator