当前位置:网站首页>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 :
边栏推荐
- PMIX ERROR: ERROR in file gds_ds12_lock_pthread.c
- LAN SDN technology hard core insider 10 cloud converged matchmaker evpn
- What if Adobe pr2022 doesn't have open subtitles?
- Sqlserver backup restore
- Successfully solved: error: SRC refspec master doors not match any
- D2DEngine食用教程(3)———将渲染目标导出为图像文件
- IPhone binding 163 mailbox solution
- C语言经典习题之猴子吃桃问题
- Energy principle and variational method note 11: shape function (a dimension reduction idea)
- 6-13 vulnerability exploitation -smtp brute force cracking
猜你喜欢

swagger2的初步使用

C语言经典习题之猴子吃桃问题

Listen for the scroll event @scroll of div

Once svchost Troubleshooting of exe process occupying a large amount of network bandwidth

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

直播课堂系统04-创建service模块

mysql服务1主2从,主主,MHA配置详细步骤

NFT insider 67: Barcelona Football Club launched its first NFT work, and Dubai launched the national metauniverse strategy

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

flask框架中页面跳转与重定向
随机推荐
C语言经典习题之评委打分去掉最高最低求平均分
How to prevent SQL injection in PHP applications
Text attack methods open source code summary
Combinatorial number (number of prime factors of factorials, calculation of combinatorial number)
CONDA common commands
Analyze the real-time development method of Bank of London
Listen for the scroll event @scroll of div
Er system, in Lin reply bit, count, successfully open r com change
Shell语法(二)
致-.-- -..- -
Privacy protection federal learning framework supporting most irregular users
Traversal of binary tree
如何用STATA进行chowtest
Particle Designer: particle effect maker, which generates plist files and can be used normally in projects
ARP Spoofing protection of network security
MOS cameraization and digitization "includes designation (contro. skilled
Leetcode 20 valid parentheses, 33 search rotation sort array, 88 merge two ordered arrays (nums1 length is m+n), 160 intersecting linked list, 54 spiral matrix, 415 character addition (cannot be direc
Redis sentinel mode, master node check script
Jinglianwen technology provides 3D point cloud image annotation service
Smart people's game improvement: Chapter 3 Lesson 3 example: the secret of prime