8424432925592889329288197322308900672459420460792433
September 1, 2020
This blog is about programming, not proving math theorems, so you probably guessed that there is a counter example. You might have even noticed the hint in the title.
(define (f n) (gcd (+ (expt n 17) 9) (+ (expt (+ n 1) 17) 9)))
> (map f (range 50)) (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) > (f 8424432925592889329288197322308900672459420460792433) 8936582237915716659950962253358945635793453256935559
No, nobody wrote a program to calculate that 52-digit number; the problem was constructed using some theorems of number theory. And yes, that 52-digit number is the smallest counter example to the conjecture. A010034 explains how to calculate the infinite sequence of such numbers, and shows the first hundred of them. You might also enjoy this video.
You can see the program at http://ideone.com/tdFHd1, but it doesn’t work because Chicken tries to perform the gcd
calculation using floating-point arithmetic, which overflows.
Here is my take on it using Julia: https://pastebin.com/AKTLZNee
Although it’s not solid proof, I checked n values up to 10 000 000 and couldn’t find an exception to this rule. However, there could be a case for higher values of n where the two values are not coprime. Cheers!
Here’s a C++ solution that conducts the search in parallel, using GMP for arbitrary-precision integers and OpenMP for multiprocessing.
Given how large the smallest counterexample is, starting the search from zero is practically ineffective.
When starting the search one billion numbers away, the counterexample is found after about 20 minutes on my 8 core (2 threads per core) processor. However, this approach would also be ineffective if I didn’t check the solution from @programmingpraxis, as I wouldn’t know where to start searching.
Example usage:
Another example:
(n^19 + 6) and (n+1)^16 + 9
n = 1578270389554680057141787800241971645032008710129107338825798
gcd = 5299875888670549565548724808121659894902032916925752559262837
[…] best widespread divisor isn’t 1. When you find yourself completed, you might be welcome to learn or run a prompt answer, or to submit your individual answer or focus on the train within the […]