Solved Jan. 2011, found today ðŸ˜‰

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/usr/bin/calc -d -f define main() { local i, j, prime, combined, n, sidelen; prime = 0; combined = 1; ## because of the 1 in the middle n = 1; sidelen = 1; for( i=1; i<1000000; i++ ) { for( j=0; j<4; j++ ) { n += 2*i; if( isprime(n) ) ++prime; else ++combined; } sidelen += 2; print sidelen, ":", prime, "/", combined; if( 10*prime < (prime+combined) ){ print "below 10% at side length of ", sidelen, "(n =", n, ")"; return 0; } } return 0; } main(); |

And the same in C++ with libgmp:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include <iostream> #include <gmp.h> #include <gmpxx.h> using namespace std; int main() { mpz_class i, j, n; int prime, combined, sidelen; prime = 0; combined = 1; // because of the 1 in the middle n = 1; sidelen = 1; for( i=1; ; i++ ) { for( j=0; j<4; j++ ) { n += 2*i; if( mpz_probab_prime_p(n.get_mpz_t(), 100) ) ++prime; else ++combined; } sidelen += 2; //cout << sidelen << ": " << prime << " / " << combined << endl; if( 10*prime < (prime+combined) ) { cout << "below 10% at side length of " << sidelen << "(n = " << n << ")" << endl; return 0; } } return 0; } |