Example #1
0
int main(int argc, char **argv)
{
	char *sosuFile = makeTempFile("sosu");
	uint64 value;
	uint64 max = toValue64(nextArg());

	errorCase(max < 11);
	errorCase(max == UINT64MAX);

	SosuFp = fileOpen(sosuFile, "a+b");
	SosuCnt = 0;

	for(value = 11; value <= max; value += 2)
	{
		if((value & 0x3ffe) == 0)
			cmdTitle_x(xcout("Prime2tox - %I64u", value));

		if(
			value % 3 != 0 &&
			value % 5 != 0 &&
			value % 7 != 0 &&
			IsSosu(value)
			)
			AddSosu(value);
	}
	cmdTitle("Prime2tox - Completed");
	DispSosu();

	fileClose(SosuFp);
	removeFile(sosuFile);
	memFree(sosuFile);
}
Example #2
0
int main(void)
{
	sosu = (int *)malloc(sizeof(int) * 1000000);
	
	sosu[0] = 2;
	double sum = 2;
	int num = 1;
	
	for (int i = 3; i <= 2000000; i += 2)
	{
		if (IsSosu(i))
		{
			sum += i;
			sosu[num++] = i;
		}
	}
	
	printf("%f\n", sum);
	
	free(sosu);
	return 0;
}