1
0
Fork 0

Edited problems 35, 37 to use long version of primes.c.

This commit is contained in:
Jonathan Chan 2016-12-06 11:45:18 -08:00
parent 509cb46f37
commit 5bfa0b53a2
4 changed files with 8 additions and 8 deletions

BIN
35

Binary file not shown.

8
35.c
View File

@ -7,14 +7,14 @@
int main () {
int bound = 1000000;
int* primes;
long* primes;
bool* primesTable;
int numPrimes = listOfPrimes (bound, &primes, &primesTable);
long numPrimes = listOfPrimes (bound, &primes, &primesTable);
bool* circularPrimesTable = calloc (bound + 1, sizeof (bool));
for (int i = 0; i < numPrimes; i++) {
for (long i = 0; i < numPrimes; i++) {
if (circularPrimesTable[primes[i]] != true) {
int n = primes[i];
long n = primes[i];
int numOfDigits = floor (log10 (n)) + 1;
int* digits = malloc (sizeof (int) * numOfDigits);
for (int d = 0; d < numOfDigits; d++) {

BIN
37

Binary file not shown.

8
37.c
View File

@ -25,13 +25,13 @@ bool isRightTrunc (int n) {
}
int main () {
int* primes;
int numOfPrimes = listOfPrimes (1000000, &primes, &primesTable);
long* primes;
long numOfPrimes = listOfPrimes (1000000, &primes, &primesTable);
// unfortunately I couldn't find a deterministic way to find
// the upper-bound of all truncatable primes... 1 mil will do
int sum = 0;
for (int i = 0; i < numOfPrimes; i++) {
long sum = 0;
for (long i = 0; i < numOfPrimes; i++) {
if (isLeftTrunc (primes[i]) &&
isRightTrunc (primes[i]) &&
primes[i] > 10) {