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.

A332941 Lexicographically earliest sequence of positive numbers in which no set of consecutive terms sums to a prime.

This page as a plain text file.
%I A332941 #26 Jan 21 2023 19:43:28
%S A332941 1,8,1,15,9,1,14,6,30,6,9,15,6,4,8,12,10,14,6,12,8,10,12,18,12,6,6,6,
%T A332941 24,6,6,8,1,9,6,10,8,12,6,14,10,6,4,8,12,10,20,6,18,6,6,4,8,12,6,4,12,
%U A332941 8,10,8,6,6,18,6,6,20,10,12,8,4,6,12,12,6,12,6,12
%N A332941 Lexicographically earliest sequence of positive numbers in which no set of consecutive terms sums to a prime.
%C A332941 Terms >= 30 seem to be very rare. Up to a(450000), 30 appears only 7 times: at n = 9, 288, 2507, 15902, 54405, 242728, 425707.
%C A332941 For n <= 450000, the largest term is 32; it appears at n = 335308 and 370687.
%H A332941 Alois P. Heinz, <a href="/A332941/b332941.txt">Table of n, a(n) for n = 1..10000</a>
%p A332941 s:= proc(i, j) option remember; `if`(i>j, 0, a(j)+s(i, j-1)) end:
%p A332941 a:= proc(n) option remember; local k; for k while
%p A332941       ormap(isprime, [k+s(i, n-1)$i=1..n]) do od; k
%p A332941     end:
%p A332941 seq(a(n), n=1..100);  # _Alois P. Heinz_, Mar 23 2020
%t A332941 s[i_, j_] := s[i, j] = If[i > j, 0, a[j] + s[i, j-1]];
%t A332941 a[n_] := a[n] = Module[{k}, For[k = 1, AnyTrue[k+Table[s[i, n-1], {i, 1, n}], PrimeQ], k++]; k];
%t A332941 Array[a, 100] (* _Jean-François Alcover_, Nov 17 2020, after _Alois P. Heinz_ *)
%o A332941 (Python)
%o A332941 def A(ee):
%o A332941     a=[1]
%o A332941     print(1)
%o A332941     n=1
%o A332941     while n<=ee:
%o A332941         i=1
%o A332941         while i>0:
%o A332941             ii=i
%o A332941             iz=c=0
%o A332941             while iz<=len(a):
%o A332941                 c=0
%o A332941                 if ii>2:
%o A332941                     for j in range(2, int((ii)**0.5+1.5)):
%o A332941                         if ii%j==0:
%o A332941                             c=1
%o A332941                             break
%o A332941                 if c==0 and ii>1:
%o A332941                     break
%o A332941                 else:
%o A332941                     iz += 1
%o A332941                     ii=ii+a[n-iz]
%o A332941             if c==1:
%o A332941                 n += 1
%o A332941                 a.append(i)
%o A332941                 print(i)
%o A332941                 break
%o A332941             if i<4:
%o A332941                 i=4
%o A332941             else:
%o A332941                 i += 1
%o A332941     return a
%Y A332941 Cf. A254337, A084833.
%K A332941 nonn
%O A332941 1,2
%A A332941 _S. Brunner_, Mar 03 2020