Determine the smallest pair of twin primes A and B, such that when concatenated, A and B will contain all 10 decimal digits.
clearvars
p=primes(99999999);
for i=1:length(p)-1
if p(i+1)==p(i)+2;
tst=unique([char(string(p(i))) char(string(p(i+1)))]);
if length(tst)==10
disp([p(i) p(i+1)])
end
end
end
finds
>> conjoinedTwins
20487359 20487361
23074859 23074861
23087459 23087461
24078359 24078361
24807359 24807361
27480359 27480361
28034759 28034761
28743059 28743061
30482759 30482761
32784599 32784601
34702859 34702861
37048259 37048261
37840259 37840261
43807259 43807261
43827059 43827061
46508729 46508731
47058629 47058631
47302859 47302861
47865029 47865031
48273059 48273061
48605729 48605731
50748629 50748631
50876429 50876431
54708629 54708631
56074829 56074831
57468029 57468031
57604829 57604831
60584729 60584731
64085729 64085731
64807529 64807531
65407829 65407831
68407529 68407531
68504729 68504731
70482359 70482361
70824359 70824361
72340859 72340861
72380459 72380461
72438059 72438061
72843059 72843061
73084259 73084261
73802459 73802461
74068529 74068531
74238599 74238601
74328599 74328601
74380259 74380261
75468299 75468301
75860429 75860431
76058429 76058431
76405829 76405831
76408529 76408531
76508429 76508431
78023459 78023461
80465729 80465731
80657429 80657431
80765429 80765431
82374599 82374601
82407359 82407361
82734599 82734601
83702459 83702461
84032759 84032761
84506729 84506731
84657299 84657301
85067429 85067431
85674299 85674301
86547029 86547031
86705429 86705431
87032459 87032461
87465029 87465031
87654029 87654031
so the first such pair is (20487359, 20487361).
|
Posted by Charlie
on 2023-10-20 12:34:16 |