0
点赞
收藏
分享

微信扫一扫

今日学习在线编程题:真因子

八卦城的酒 2022-05-01 阅读 50

 题目来源:码蹄集

https://matiji.net/exam/brushquestion/153/778/B3FCFEC101BD05189BB74D522E019504 ​​​​​​​

时间限制:1000ms
内存限制:65535kb


题目描述:输入正整数N,计算其所有真因子之和。自然数的真因子是严格小于该数 的除数。


输入格式:输入正整数N
输出格式:输出整型


输入样例:10
输出样例:8

参考程序

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	long long N,ans=0;
	int ret = scanf("%lld", &N);
	for (long long i = 1; i <= (N / 2) + 1; i++) {
		if (N%i == 0)
			ans += i;

	}
	printf("%lld", ans);
	return 0;
}

​​​​​​​

举报

相关推荐

0 条评论