Determine all possible pairs of positive integers satisfying each of these conditions:
- The last digit of their sum is 5.
- Their difference is a prime number.
- Their product is a perfect square.
clearvars,clc
for s=5:10:10000000
for a=1:s/2
b=s-a;
if isprime(b-a)
sq=a*b;
sr=round(sqrt(sq));
if sr^2==sq
fprintf('%5d %5d %5d %5d %10d %5d\n',a, b, s, b-a, sq, sr)
end
end
end
end
provides the first few, until stopped:
a b a+b b-a a*b sqrt(a*b)
1 4 5 3 4 2
9 16 25 7 144 12
36 49 85 13 1764 42
64 81 145 17 5184 72
121 144 265 23 17424 132
324 361 685 37 116964 342
441 484 925 43 213444 462
529 576 1105 47 304704 552
676 729 1405 53 492804 702
1089 1156 2245 67 1258884 1122
1296 1369 2665 73 1774224 1332
1681 1764 3445 83 2965284 1722
2304 2401 4705 97 5531904 2352
2601 2704 5305 103 7033104 2652
2809 2916 5725 107 8191044 2862
3136 3249 6385 113 10188864 3192
3969 4096 8065 127 16257024 4032
4624 4761 9385 137 22014864 4692
6084 6241 12325 157 37970244 6162
6561 6724 13285 163 44116164 6642
6889 7056 13945 167 48608784 6972
7396 7569 14965 173 55980324 7482
9216 9409 18625 193 86713344 9312
9604 9801 19405 197 94128804 9702
12321 12544 24865 223 154554624 12432
12769 12996 25765 227 165945924 12882
13456 13689 27145 233 184199184 13572
16384 16641 33025 257 272646144 16512
17161 17424 34585 263 299013264 17292
Both summands seem to be perfect squares, but other than that I don't see a commonality other than what was required. It seems only one value of b-a comes up for a given b+a and these prime values come up in increasing order as a+b increases. Not every prime shows up.
|
Posted by Charlie
on 2023-01-21 09:11:18 |