当前位置:网站首页>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;
}
边栏推荐
- How to add a mask of a target in a picture
- Database storage - table partition
- Greenplum 6.x build_ install
- 如何在快应用中实现滑动操作组件
- Greenplum 6.x monitoring software setup
- Greenplum 6.x version change record common manual
- Routing information protocol rip
- About using CDN based on Kangle and EP panel
- ncs成都新電面試經驗
- Required String parameter ‘XXX‘ is not present
猜你喜欢
数字三角形模型 AcWing 275. 传纸条
ncs成都新電面試經驗
Greenplum6.x重新初始化
Lenovo hybrid cloud Lenovo xcloud: 4 major product lines +it service portal
Image segmentation in opencv
LeetCode 715. Range 模块
Simple use of Xray
[Yugong series] February 2022 U3D full stack class 006 unity toolbar
LeetCode 736. Lisp 语法解析
Why choose cloud native database
随机推荐
Markdown editor Use of MD plug-in
Alibaba P8 teaches you how to realize multithreading in automated testing? Hurry up and stop
Image segmentation in opencv
ncs成都新电面试经验
[step on the pit] Nacos registration has been connected to localhost:8848, no available server
详解华为应用市场2022年逐步减少32位包体上架应用和策略
xray的简单使用
关于基于kangle和EP面板使用CDN
Speaking of a software entrepreneurship project, is there anyone willing to invest?
調用華為遊戲多媒體服務的創建引擎接口返回錯誤碼1002,錯誤信息:the params is error
Pointer advanced, string function
数据库存储---表分区
Explain Huawei's application market in detail, and gradually reduce 32-bit package applications and strategies in 2022
【微信小程序:缓存操作】
登山小分队(dfs)
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
redis故障处理 “Can‘t save in background: fork: Cannot allocate memory“
NCS Chengdu Xindian interview experience
[Yugong series] February 2022 U3D full stack class 006 unity toolbar
[wechat applet: cache operation]