我是靠谱客的博主 体贴大侠,这篇文章主要介绍**[Loops]D. Liang 4.16 Finding the factors of an integer**,现在分享给大家,希望可以做个参考。

C语言作业记录。
Description
Write a program that reads an integer n and displays all its smallest factors. For example, if the input ingeger is 120, the output should be as follows: 2 2 2 3 5

Input
An integer n (1<n<20000).

Output
The smallest factors of n in nondescending order, each factor per line.

Sample Input
120

Sample Output
2 2 2 3 5

#include<stdio.h>
int main(void)
{    
     int n,a=2;
     scanf("%d",&n);
     while(n!=1){
     
        if(n%a==0)
        { n/=a;
          printf("%dn",a);
        }
        else
         a++;
     }
     
    return 0;
}

最后

以上就是体贴大侠最近收集整理的关于**[Loops]D. Liang 4.16 Finding the factors of an integer**的全部内容,更多相关**[Loops]D.内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(132)

评论列表共有 0 条评论

立即
投稿
返回
顶部