【c语言】查找某个数后的n个素数

来源:互联网 发布:淘宝新店该怎么做 编辑:程序博客网 时间:2024/05/07 13:31

/* ============================================================================ Name        : HelloWorld.c Author      : moshiyou@163.com Version     : Copyright   : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */#include <stdio.h>#include <stdlib.h>int sushu(int n) {int i,r;for (i = 2; i <= n - 1; i++) {r = n % i;if (r == 0)break;}if (i >= n)return 1;elsereturn 0;}int main(void) {int m,k,i,j;scanf("%d %d",&m,&k);printf("整數%d后的%d個素數為:",m,k);j = 1;for(i=m+1;;i++){if(sushu(i) == 1){printf("%d\t",i);j++;}if(j>k)break;}return EXIT_SUCCESS;}

查找素数


0 0