Could one find a sequence of 14 consecutive positive integers such that:
(I) each of the members of such sequence will be divisible by a prime below 13?
(II) Same question for 21 members, each being divisible by a prime below 17?
Provide two independent answers for (I) and (II)
clearvars,clc
disp('I')
good=true;
div=[2 3 5 7 11];
nlist=2; ct=0;
for n=nlist+1:999999
nlist(end+1)=n;
if sum(mod(n,div)==0)
good(end+1)=true;
else
good(end+1)=false;
end
if length(nlist)>14
nlist=nlist(end-13:end);
good=good(end-13:end);
end
if sum(good)==14
disp([nlist(1) nlist(end)])
ct=ct+1;
if ct>2
break
end
end
end
disp('II')
clearvars
good=true;
div=[2 3 5 7 11 13];
nlist=30; ct=0;
for n=nlist+1:999999
nlist(end+1)=n;
if sum(mod(n,div)==0)
good(end+1)=true;
else
good(end+1)=false;
end
if length(nlist)>21
nlist=nlist(end-20:end);
good=good(end-20:end);
end
if sum(good)==21
disp([nlist(1) nlist(end)])
ct=ct+1;
if ct>2
break
end
end
end
I
II
first last
member member
9440 9460
20570 20590
39470 39490
|
Posted by Charlie
on 2023-11-10 07:53:23 |