Kenny has gone to a lecture by Jenny, a famous mathematician. Kenny tells Lenny that Jenny handed everyone at the lecture 2 cards, one containing a 5-digit prime, and the other containing a 5-digit square. All of the cards held different numbers.
Then she asked everyone to add their 2 numbers, and amazingly they all got the same sum. Kenny says it's lucky that Lenny didn't attend, because then the trick would have been impossible.
What was the sum they all got?
grid=zeros(8363,217);
prime1=nextprime(10000)
pptr1=whichprime(prime1)
pptrlast=whichprime(prevprime(99999));
pr=prime1;
for pptr=pptr1:pptrlast
for n=100:316
sq=n^2;
grid(pptr-pptr1+1,n-99)=pr+sq;
end
pr=nextprime(pr+1);
end
list=sort(reshape(grid,1,numel(grid)));
prev=0; ct=0; mx=0;
for i=1:length(list)
if list(i)==prev
ct=ct+1;
else
if ct>mx
mx=ct;
mxsum=prev;
end
ct=1;
end
prev=list(i);
end
if ct>mx
mx=ct;
mxsum=prev;
end
mx
mxsum
finds they all got 101888 and there were 69 attendees, as that is the number of such totals that can be made that are all equal, and it's the maximum such number.
Changing the program to show all the 101888 totals gives:
prime square sq root
10079 91809 303
11287 90601 301
12487 89401 299
13679 88209 297
17207 84681 291
18367 83521 289
20663 81225 285
21799 80089 283
26263 75625 275
28447 73441 271
29527 72361 269
31663 70225 265
32719 69169 263
33767 68121 261
34807 67081 259
35839 66049 257
37879 64009 253
39887 62001 249
40879 61009 247
41863 60025 245
42839 59049 243
46663 55225 235
47599 54289 233
48527 53361 231
50359 51529 227
51263 50625 225
53047 48841 221
53927 47961 219
54799 47089 217
55663 46225 215
56519 45369 213
57367 44521 211
58207 43681 209
59863 42025 205
60679 41209 203
61487 40401 201
63079 38809 197
63863 38025 195
65407 36481 191
66919 34969 187
68399 33489 183
69127 32761 181
69847 32041 179
71263 30625 175
72647 29241 171
73327 28561 169
73999 27889 167
75967 25921 161
76607 25281 159
77239 24649 157
77863 24025 155
78479 23409 153
79087 22801 151
79687 22201 149
80279 21609 147
80863 21025 145
81439 20449 143
82007 19881 141
82567 19321 139
83663 18225 135
84199 17689 133
85247 16641 129
86263 15625 125
88663 13225 115
89119 12769 113
89567 12321 111
90007 11881 109
90439 11449 107
90863 11025 105
|
Posted by Charlie
on 2023-12-16 13:32:41 |