当前位置:网站首页>-完全数-
-完全数-
2022-08-03 05:10:00 【-JMY-】
题目描述
求2~n之间的所有完全数;完全数是指该数的所有因数(除了本身)之和等于原数,如6=1+2+3
输入
一个正整数n
输出
n以内所有的完全数,每个数之间用空格隔开。
样例输入
7
样例输出
6
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,s;
cin>>n;
for(int i=2;i<=n;i++){
s=0;
for(int j=1;j<i;j++){
if(i%j==0)
s+=j;
}
if(s==i)
cout<<i<<' ';
}
}
边栏推荐
- Djiango第二次培训
- Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
- Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
- Detailed explanation of MOSN reverse channel
- 获取Ip工具类
- FileZilla 搭建ftp服务器
- typescript49-交叉类型
- Pr第四次培训笔记
- Get the Ip tool class
- Exception (abnormal) and Error (error) difference analysis
猜你喜欢

13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence 
web安全-PHP反序列化漏洞

Redis常用命令

Secondary development of WinForm controls

celery工作原理图

2. 两数相加

用scikit-learn学习谱聚类

Redis6学习笔记

Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data

传说中可“免费白拿”的无线路由器 - 斐讯 K2 最简单刷 breed 与第三方固件教程
随机推荐
C-PHY速率
快速上手 Mockito 单元测试框架
Tag stack - stack monotonically preparatory knowledge - lt. 739. The daily temperature
Super handy drawing tool is recommended
高可用 两地三中心
Object类与常用API
【Flask】Flask-SQLAlchemy的增删改查(CRUD)操作
Presto installation and deployment tutorial
Alienware上线首个数字时装AR试穿体验
Gradle的安装配置
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
-查找数-
Length n of condensed distance matrix ‘y‘ must be a binomial coefficient
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
FileZilla 搭建ftp服务器
JS学习笔记(三)
shell脚本循环语句
[Harmony OS] [ArkUI] ets development graphics and animation drawing
接口和抽象