What are 19 consecutive 4-digit primes such that the difference between the greatest prime and the least prime is less than 100?
p=setdiff(primes(9999),primes(999));
for i=1:length(p)-18
if p(i+18)-p(i)<100
fprintf('%4d ',p(i:i+18))
fprintf('\n')
end
end
finds
2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753
|
Posted by Charlie
on 2024-09-19 08:00:34 |