Skip to content

Instantly share code, notes, and snippets.

@uhfx uhfx/sosu.c
Last active Dec 27, 2015

Embed
What would you like to do?
【超高速】素数を求めるプログラム
#include <stdio.h>
#include <math.h>
int main(void)
{
int i,j,k;
printf("2 "); //あらかじめ2を書いておくという手法
for(i=10;i<=100;i+=2) //ここのiの値と10000の値をいじれば変わる
{
k=0;
for(j=3;j<=sqrt(i);j+=2)
{
if(i%j==0)
{
k=1;
break;
}
}
if(k==0) printf("%d ",i);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.