最大约数和高次方尾数

来源:互联网 发布:淘宝迅雷白金会员 编辑:程序博客网 时间:2024/06/05 20:23

第一题:求555555约数中最大的三位数是多少?

代码:

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


int main()
{
long i;
int j;

scanf ("%ld" , &i);

for (j = 999;j >=100;j++)
if(i % j == 0)
{
printf("the max factor with 3 digits in %ld.\n",i,j);
break;
}

return 0;
}



第二题:求13的13次方的最后三位数

代码:

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


int main()
{
int i,x,y,last = 1;
printf("input X and Y (X * * Y):");
scanf("%d * * %d",&x,&y);
for(i=1;i<=y;i++)
last = last * x%1000;
printf("the last 3 digits of %d* *%d is: %d\n",x,y,last%1000);

return 0;
}

0 0
原创粉丝点击