30 semiprimes, each less than 10
8, form an arithmetic sequence with strictly positive common difference.
Determine all of them.
Note: A semiprime is the product of exactly two primes.
*** For an extra challenge only, find a semi-analytic solution (simple calculator + p&p) to this puzzle.
% nos=repmat('0',1,99999999);
% for i=4:99999999
% if length(factor(i))==2
% nos(i)='1';
% end
% end
% fid=fopen('c:b5 projectslooblesemiprimes.txt','w');
% fprintf(fid,'%s
',nos);
% fclose(fid);
%
fid=fopen('c:b5 projectslooblesemiprimes.txt','r');
isSemi=fgetl(fid);
fclose(fid);
l=length(isSemi); o=ones(1,30);
for diff=floor(l/30):-1:2626
for st=1:diff-1
last=st+diff*floor((99999999-st)/diff);
tst=isSemi(st:diff:last);
ix=strfind(tst,o);
if ~isempty(ix)
disp([diff st ix(1)])
disp(ix)
disp(' ')
end
end
end
The commented part (% signs) produced a file with 1's for semiprimes and zeros for the other integers, up to the limit specified.
The still-active code attempted to try all possible intervals, and starting points relative to the given interval, to find a sequentially positioned set of 1's, but there are too many possibilities to run in a realistic time frame.
It does call for some analysis to at least whittle down the possibilities.
Edited on November 20, 2022, 11:08 am
|
Posted by Charlie
on 2022-11-20 11:07:03 |