Example #1
0
int main()
{
    int count;
    long sum, i;
    count = 0;
    sum = 0;
    for (i = 11; count < 11; i += 2)
	if (truncatable_prime(i)) {
	    sum += i;
	    count++;
	}

    printf("%d\n", sum);
}
Example #2
0
int main(void){
	clock_t ini = clock();
	int ans = 0, c = 0;
	for(int i = 0; i < MAX; ++i) p[i] = 1;
	p[0] = p[1] = 0;
	for(int i = 4; i < MAX; i += 2) p[i] = 0;
	for(int i = 3; i < SQMAX; i += 2)
		if(p[i]) for(int j = i * i; j < MAX; j += i) p[j] = 0;
	for(int i = 11; c < 11; i += 2) 
		if(truncatable_prime(i)) ans += i, ++c;
	printf("Time spent: %.3lfs\n", ((double)(clock() - ini))/CLOCKS_PER_SEC);
	printf("Answer: %d\n", ans);
	return 0;
}
Example #3
0
int main(){
  int n = 7;
  int count = 0;
  int result = 0;

  while (count < 11){
    n = next_prime(n);
    if(truncatable_prime(n)){ 
      result += n;
      count++;
    }
  }

  std::cout << result << std::endl;
}