cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A371155 a(n) depends on the primality of a(n-1) and parity of n (see Comments lines for definition).

This page as a plain text file.
%I A371155 #32 Nov 25 2024 14:53:17
%S A371155 1,2,3,5,6,4,5,7,8,6,7,11,12,8,9,10,11,13,14,12,13,17,18,14,15,16,17,
%T A371155 19,20,18,19,23,24,20,21,22,23,29,30,24,25,26,27,28,29,31,32,30,31,37,
%U A371155 38,32,33,34,35,36,37,41,42,38,39,40,41,43,44,42,43,47
%N A371155 a(n) depends on the primality of a(n-1) and parity of n (see Comments lines for definition).
%C A371155 Initial term a(1)=1 and thereafter:
%C A371155 If n is even and a(n-1) is prime, then a(n) = least prime > a(n-1).
%C A371155 If n is even and a(n-1) is composite and a(n-2) is prime, then a(n) = 1 + greatest prime < a(n-2).
%C A371155 Otherwise, a(n) = a(n-1) + 1.
%C A371155 Every integer will be seen, with many seen twice. Largest first differences will be at prime gaps. Starting at 3, pairs of consecutive primes appear. Interestingly, the values seen once seem to correspond to A093513 except for 2.
%H A371155 Bill McEachen, <a href="/A371155/b371155.txt">Table of n, a(n) for n = 1..10000</a>
%e A371155 From 2 we move to 3, it is prime, so go to 5. Next evaluation to 6, having departed from a prime, so go to 3 + 1 = 4. Next eval move to 5, it is prime, so go to 7. Next eval to 8, having departed from a prime, so go to 5 + 1 = 6. Next eval move to 7, it is prime, so go to 11. Next eval move to 12, having departed from a prime, so go to 7 + 1 = 8. Next eval move to 9. Next eval move to 10. Next eval move to 11, it is prime, so go to 13. This example adds the terms 3, 5, 6, 4, 5, 7, 8, 6, 7, 11, 12, 8, 9, 10, 11, 13.
%t A371155 a[1] = 1; a[n_] := a[n] = If[EvenQ[n], If[PrimeQ[a[n-1]], NextPrime[a[n-1] + 1], If[CompositeQ[a[n-1]] && PrimeQ[a[n-2]], 1 + NextPrime[a[n-2], -1], a[n-1] + 1]], a[n-1] + 1]; Array[a, 100] (* _Amiram Eldar_, Mar 19 2024 *)
%Y A371155 Cf. A093513.
%K A371155 nonn,easy
%O A371155 1,2
%A A371155 _Bill McEachen_, Mar 13 2024