当前位置:网站首页>Output all composite numbers between 6 and 1000
Output all composite numbers between 6 and 1000
2022-07-07 08:53:00 【Please Sit Down】
subject : Write a program to output in 6~1000 All the sums of , Composite refers to 1 The number equal to the sum of its factors . for example ,6=1+2+3,28=1+2+4+7+14, be 6、28 It's a total number .
int main(void)
{
int i, k, sum;
printf("6~1000 All composite numbers between :\n");
for (i = 6; i <= 1000; i++) // The range of the number judged by the outer loop control is 6-1000
{
sum = 0;
for (k = 1; k < i; k++) // The inner loop finds the sum of the factors of a number
if (i % k == 0)
sum += k;
if (i == sum) // Number of judgements i Whether it is the sum of its factors sum equal , If equal , Is a composite number
printf("%d\t", i);
}
return 0;
}
边栏推荐
- 年薪50w阿裏P8親自下場,教你如何從測試進階
- Database storage - table partition
- Qt Charts使用(重写QChartView,实现一些自定义功能)
- opencv之图像分割
- The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
- [wechat applet: cache operation]
- NCS Chengdu Xindian interview experience
- 为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
- ncs成都新电面试经验
- Category of IP address
猜你喜欢
数据分析方法论与前人经验总结2【笔记干货】
Greenplum 6.x common statements
Lenovo hybrid cloud Lenovo xcloud: 4 major product lines +it service portal
Routing information protocol rip
Greenplum6.x常用语句
Why choose cloud native database
Count sort (diagram)
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
数字三角形模型 AcWing 1027. 方格取数
leetcode134. gas station
随机推荐
[Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
Mountaineering team (DFS)
Alibaba P8 teaches you how to realize multithreading in automated testing? Hurry up and stop
Upload an e-office V9 arbitrary file [vulnerability recurrence practice]
Newly found yii2 excel processing plug-in
Count sort (diagram)
Required String parameter ‘XXX‘ is not present
[Nanjing University] - [software analysis] course learning notes (I) -introduction
【微信小程序:缓存操作】
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
LeetCode 715. Range 模块
What is the method of manual wiring in PCB design in 22protel DXP_ Chengdu electromechanical Development Undertaking
Analysis of abnormal channel number information before and after AGC re signature service
Nanjing commercial housing sales enabled electronic contracts, and Junzi sign assisted in the online signing and filing of housing transactions
[Yu Yue education] basic reference materials of electrical and electronic technology of Nanjing Institute of information technology
Digital triangle model acwing 275 Pass a note
Routing information protocol rip
测试踩坑 - 当已有接口(或数据库表中)新增字段时,都需要注意哪些测试点?
模拟卷Leetcode【普通】1557. 可以到达所有点的最少点数目
AVL balanced binary search tree