#include<stdio.h>#include<math.h>#definefalse0#definetrue1intmain(int argc,char*argv[]){int count =0;for(int i =3; i <100; i +=2){int state = true;for(int j =3; j <=sqrt(i); j +=2){
count++;if(!(i % j)){
state = false;break;}}if(state){printf("%d\n", i);}}printf("一共迭代%d次", count);}
最大公约数,最小公倍数
#include<stdio.h>intmain(int argc,char*argv[]){int a, b;scanf("%d%d",&a,&b);if(a < b){
a = b + a;
b = a - b;
a = a - b;}int c = a % b;int a_clone, b_clone = b;while(c){printf("%d\n", c);
a_clone = b_clone;
b_clone = c;
c = a_clone % b_clone;}printf("最大公约数:%d\n", b_clone);printf("最小公倍数:%d",(b * a)/ b_clone);}