1
0
Fork 0

Problem 87

This commit is contained in:
Jonathan Chan 2018-09-01 11:06:47 -07:00
parent 1d8678eeb5
commit f326fd7c77
2 changed files with 4 additions and 3 deletions

BIN
87

Binary file not shown.

7
87.c
View File

@ -14,16 +14,16 @@ int main(void) {
long* primes;
bool* primesTable;
int length = listOfPrimes(sqrt(SIZE - 24), &primes, &primesTable);
//bool visited[SIZE] = {false};
bool* visited = calloc(SIZE, sizeof(bool));
int count = 0;
for (int i = 0; i < length && primes[i] <= 7069; i++) {
for (int j = 0; j < length && primes[j] <= 367; j++) {
for (int k = 0; k < length && primes[k] <= 83; k++) {
int n = pow(primes[i], 2) + pow(primes[j], 3) + pow(primes[k], 4);
if (n < SIZE) { //&& !visited[n]) {
if (n < SIZE && !visited[n]) {
count++;
//visited[n] = true;
visited[n] = true;
}
}
}
@ -33,4 +33,5 @@ int main(void) {
free(primes);
free(primesTable);
free(visited);
}