程序代码:
/* Note:Your choice is C IDE */
//欧几里得的辗转相除法 基本思路!
#include "stdio.h"
int main()
{
long int x,y,z;
puts("pleas input two number.");
scanf( "%d%d" ,&x , &y);
z = x % y;
while(z != 0)
{
//变换变量的值
x=y;
y=z;
z=x % y;
}
if(y==1)printf("this two number is prime number!");
else printf("this two number is not prime number!\nhave greatest common divisor is:%d",y);
return 0;
}
/* Note:Your choice is C IDE */
//欧几里得的辗转相除法 具体解法!
#include "stdio.h"
int main()
{
long int x,X1,y,Y1,z;
puts("prime number list:");
for(X1=1;X1<=4000;X1++) //4000的只有点大,要计算很一会了
for(Y1=1;Y1<=4000;Y1++)
{
x=X1;
y=Y1;
z = x % y;
while(z != 0)
{
//变换变量的值
x=y;
y=z;
z=x % y;
}
if(y==1)
{printf("%4d %4d\t",X1,Y1);}
}
return 0;
}