Esempio n. 1
0
int main(int argc, char const *argv[])
{

int i;

int N = atoi(argv[1]);

int nodesAlloc = ((N-2)/16384) + 2;

head= (  seg * ) malloc(sizeof(seg));
	pt=head;
	for (i=1;i<nodesAlloc;i++) { 
		pt->next = (  seg *) malloc(sizeof (seg)); //allocate forward nodes
		pt->prev = pt; 				   //allocate backward nodes
		pt=pt->next;
		}

	printf("Allocated %d nodes\n",i);
	
sieveOfE(N);
primecount = countPrimes(N)-1;
printf("Amount of primes = %d \n", primecount);

while(numbers != EOF){
printf("Enter your numbers or EOF:");
// if an odd integer is entered or eof is detected exit
if ( scanf("%d", &numbers) == EOF || numbers % 2 != 0 )
     {
        break;
     }
else{goldbach(numbers);}
}

   return 0;
}
Esempio n. 2
0
File: main.c Progetto: caasi/UVaOJ
int main(int argc, char *argv[])
{
	int num, a, b, result;
	while(scanf("%d", &num) != EOF)
	{
		switch(num)
		{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
				printf("Impossible.\n");
				break;
			default:
				result = goldbach(num % 2 ? num - 5 : num - 4, &a, &b);
				if(result)
					printf("2 %d %d %d\n", num % 2 ? 3 : 2, a, b);
		}
	}
	return 0;
}
Esempio n. 3
0
int main()
{
	bool tag[MAXN];
	memset(tag,false,sizeof(tag));
	findPrimes(tag);
	goldbach(tag);
	return 0;
}
Esempio n. 4
0
int main(){
    int n, largest, smallest;
    build();
    while(scanf("%d", &n) == 1 && n){
        printf("%d\n", goldbach(n));
    }

    return 0;
}
Esempio n. 5
0
int main(){
	// 1、输入一个数
	printf("请输入一个偶数");
	int num;
	scanf("%d",&num);
	// 2、判断是否为偶数
	if(num%2!=0){
		// 3.1、如果是奇数,则返回
		 return -1;
		}
		else{
	// 3.2、如果是偶数,则继续
		goldbach(num);	
	}
    printf("\n");
	return 0;
}
Esempio n. 6
0
File: 046.c Progetto: mastensg/euler
int
main()
{
    const uint_fast64_t n = 10000;
    uint_fast64_t i;

    prime_init(n);

    for (i = 3; i < n; i += 2)
    {
        if (prime(i))
            continue;

        if (!goldbach(i))
            break;
    }

    printf("%lu\n", i);

    return EXIT_SUCCESS;
}
Esempio n. 7
0
int main()
{
	goldbach(86);
	return 0;
}