Let a be a prime of the form (2n+1), and let b be a prime of the form (2a+1), such that 1/b has an even period of length 2a, i.e. 0 followed by 2a decimal digits.
The 'splitadd' function splits these 2a digits into equal halves and adds them.
To give an (imaginary) example, say 1/b was 0.0123456789, then 'splitadd' would produce 01234+56789, and add these for a value of 58023.
Show that the result of the 'splitadd' function is always (10^a-1), or find a counterexample.
The solution depends on and interpretation of "1/b has an even period of length 2a", i.e., if the period is half that, is it still considered to have a period of that full value.
clearvars, clc
for i=2:50
a=nthprime(i);
n=(a-1)/2;
b=2*a+1;
if isprime(b)
recip=1/sym(b);
end
nines=repmat('9',2*a);
nines=sym(nines(1,:));
if nines/b==round(nines/b)
s=char(string(nines/b));
lhs=s(1:floor(length(s)/2));
rhs=s(floor(length(s)/2)+1:end);
su=sym(lhs)+sym(rhs);
if su~=sym(10)^a-1
disp([a b])
disp(s)
disp(lhs)
disp(rhs)
disp(su)
disp(' ')
end
end
end
tests 2a+1 to see if it's prime; if so it assigns it to b.
Then an appropriately sized string of n's is divided by b to see if the fraction repeats with a cycle length of 2a. If it does, the splitting is done and the addition made. A report is made if the result of adding the splits is not equal to 10^a-1.
The first case it finds of a possible counterexample, the case where a=41, making b=83. While 1/83 does repeat in a "cycle" of 82, this is actually two cycles, so the cycle length, or period is really 41, which is merely a, rather than the 2a mentioned. If this situation is sufficient to meet the criteria, then this is the first counterexample. If it is not sufficient, then no counterexamples have been found.
1/83 = 0.01204819277108433734939759036144578313253,01204819277108433734939759036144578313253, ...
01204819277108433734939759036144578313253
01204819277108433734939759036144578313253
-----------------------------------------
02409638554216867469879518072289156626506 merely double the value of the real cycle taken twice.
Next report:
53 107
0.00934579439252336448598130841121495327102803738317757
00934579439252336448598130841121495327102803738317757
00934579439252336448598130841121495327102803738317757
00934579439252336448598130841121495327102803738317757
01869158878504672897196261682242990654205607476635514
The "period" is again actueally two cycles concatenated.
The same occurs with the next reported a, b pairs:
113, 227
173, 347
179, 359
Of course this situation could be considered a counterexample, if the fact that 2a digis repeat and adding the first a digits to digits a through 2a, add up to merely twice the number represented by the first a digits.
All of the following a, b pairs satisfied the conditions and passed the splitsum test, when cycle length is correctly calculated in determining eligibility:
3 7
5 11
11 23
23 47
29 59
83 167
89 179
131 263
239 479
251 503
This is the entirety of the cases that satisfy the strict criteria (b is prime and 1/b has a cycle length of 2a that is the shortest such cycle), and all of them have a split-cycle total of 10^a-1.
The revised program guards against false positives and goes all the way to the 400th prime for a: (and fixes a bug that didn't actually vet b for being prime--see the bug in the above listing)
clearvars, clc
for i=2:400
a=nthprime(i);
n=(a-1)/2;
b=2*a+1;
if isprime(b)
nines=repmat('9',2*a);
nines=sym(nines(1,:));
if nines/b==round(nines/b)
s=char(string(nines/b));
lhs=s(1:end-a);
rhs=s(end-a+1:end);
su=sym(lhs)+sym(rhs);
disp([a b])
if su~=sym(10)^a-1 && eval(sym(lhs)==sym(rhs))==false
disp([a b])
disp(s)
disp(lhs)
disp(rhs)
disp(su)
disp(' ')
end
end
end
end
checks:
3 7
5 11
11 23
23 47
29 59
41 83
53 107
83 167
89 179
113 227
131 263
173 347
179 359
191 383
233 467
239 479
251 503
281 563
293 587
359 719
419 839
431 863
443 887
491 983
509 1019
593 1187
641 1283
653 1307
659 1319
683 1367
719 1439
743 1487
761 1523
809 1619
911 1823
953 1907
1013 2027
1019 2039
1031 2063
1049 2099
1103 2207
1223 2447
1229 2459
1289 2579
1409 2819
1439 2879
1451 2903
1481 2963
1499 2999
1511 3023
1559 3119
1583 3167
1601 3203
1733 3467
1811 3623
1889 3779
1901 3803
1931 3863
1973 3947
2003 4007
2039 4079
2063 4127
2069 4139
2129 4259
2141 4283
2273 4547
2339 4679
2351 4703
2393 4787
2399 4799
2459 4919
2543 5087
2549 5099
2693 5387
2699 5399
2741 5483
This list shows only those where b is prime and either the period is smaller than 2a or the period is 2a and the splitadd adds up to 10^a-1 (only 10 cases, listed prior, satisfy that latter case).
Edited on April 7, 2022, 10:00 am
|
Posted by Charlie
on 2022-04-07 09:48:48 |