login
A354400
Replace the nonprimes in the prime gaps with primes. See Comments section for details.
1
2, 3, 5, 11, 11, 19, 17, 29, 41, 29, 59, 63, 41, 77, 95, 113, 59, 141, 129, 71, 173, 161, 203, 225, 203, 101, 221, 107, 231, 311, 269, 335, 137, 375, 149, 391, 417, 357, 455, 473, 179, 525, 191, 411, 197, 585, 645, 485, 227, 503, 645, 239, 741, 699, 729, 755, 269, 783
OFFSET
1,1
COMMENTS
Start with the sequence of the nonprime numbers. For visual clarity, it is interrupted with spaces where the primes are missing, and the nonprimes or their groups in the prime gaps are distinct:
1 4 6 8 9 10 12 14 15 16 18 20 21 22 ...
Replace the first nonprime 1 with the first prime 2 and thereafter every single or every first nonprime in the prime gaps with successive primes:
2 3 5 7 9 10 11 13 15 16 17 19 21 22 ...
Next, replace every second nonprime in the prime gaps with a new sequence of the primes:
2 3 5 7 2 10 11 13 3 16 17 19 5 22 ...
Follow by replacing every third nonprime in the prime gaps with yet another prime sequence:
2 3 5 7 2 2 11 13 3 3 17 19 5 5 ...
And so on. The sums of the substituting primes in the individual prime gaps form the terms of the sequence:
2 3 5 11 11 19 17 29 ...
PROG
(MATLAB)
function a = A354400( max_prime )
% fill the gaps
p = primes(max_prime); b = [1:max_prime];
b(isprime(b) == 0) = 0;
pj = [0 find(b > 0)]; pjo = pj;
j = pj(b(pj+1) == 0)+1;
while ~isempty(j)
b(j) = p(1:length(j));
pj = find(b(1:end-1) > 0);
if ~isempty(find(b == 0, 1))
j = pj(b(pj+1) == 0)+1;
else
j = [];
end
end
% sum the gaps
k = 1;
for n = 1:length(pjo)-1
m = sum(b(pjo(n)+1:pjo(n+1)-1));
if m > 0
a(k) = m; k = k+1;
end
end
end % Thomas Scheuerle, May 25 2022
CROSSREFS
Sequence in context: A272197 A207982 A259155 * A210144 A243357 A066159
KEYWORD
nonn
AUTHOR
Tamas Sandor Nagy, May 25 2022
STATUS
approved