题解 | #质数因子#

质数因子

https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607

#include<stdio.h>
#include<math.h>
int main()
{
int input=0;
int sqrtinput=0;
int test=2;
scanf("%d",&input);
int temp=input;
while(1)
{
	sqrtinput=sqrt(temp);
	if(test>sqrtinput)
	    {
	    	printf("%d ",temp);
	    	break;
		}
	else if(temp%test==0)
	{
		printf("%d ",test);
		temp/=test;
	}
    else
    {
    	test++;
	}
}
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务