diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-10-07 08:14:41 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-10-07 08:14:41 +0100 |
| commit | a4e10603fb553c91e50c77349a6f5d46b1cdceba (patch) | |
| tree | 3126bbe13740d1f07ddf675ec43a8006f21471de | |
| parent | 46aedfc6d8c04f384266b2e9692cf0aee564f1e0 (diff) | |
| download | perlweeklychallenge-club-a4e10603fb553c91e50c77349a6f5d46b1cdceba.tar.gz perlweeklychallenge-club-a4e10603fb553c91e50c77349a6f5d46b1cdceba.tar.bz2 perlweeklychallenge-club-a4e10603fb553c91e50c77349a6f5d46b1cdceba.zip | |
notes on computing PSIZE & move primes store in n<=PFSIZE bracket
| -rw-r--r-- | challenge-133/james-smith/c/ch-2.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/challenge-133/james-smith/c/ch-2.c b/challenge-133/james-smith/c/ch-2.c index 0a9480e21e..19b76857e3 100644 --- a/challenge-133/james-smith/c/ch-2.c +++ b/challenge-133/james-smith/c/ch-2.c @@ -1,9 +1,20 @@ #include <stdio.h> // Compute all Smith Numbers below MAX_N -#define MAX_N 1000000 + +// Use guess that PSIZE should approximately 1.1 * PFSIZE / ln(PFSIZE) + +// 10^6 +// #define MAX_N 1000000 +// #define PSIZE 42000 // Have to guess this! +// 10^8 + #define MAX_N 100000000 + #define PSIZE 3200000 // Have to guess this! +// 10^9 +//#define MAX_N 1000000000 +//#define PSIZE 28000000 // Have to guess this! + #define PFSIZE (MAX_N/2) -#define PSIZE 100000 // Have to guess this! // Set up arrays int sum_pf[ PFSIZE+1 ], primes[ PSIZE ], prime_index = 0; @@ -47,8 +58,8 @@ int sum_prime_factors( int n ) { } if( n <= PFSIZE ) { sum_pf[ n ] = sum_digits(n); + primes[ prime_index++ ] = n; } - primes[ prime_index++ ] = n; return 0; } |
