C 语言实例 - 求一个整数的所有因数

C 语言教程 · 2019-02-20 21:13:07

假如a*b=c(a、b、c都是整数),那么我们称a和b就是c的因数。

实例

#include <stdio.h> int main() { int number, i; printf("输入一个整数: "); scanf("%d",&number); printf("%d 的因数有: ", number); for(i=1; i <= number; ++i) { if (number%i == 0) { printf("%d ",i); } } return 0; }

运行结果:

输入一个整数: 60
60 的因数有: 1 2 3 4 5 6 10 12 15 20 30 60

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Machine Learning in Action

Machine Learning in Action

Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99

It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具