A233334 a(1) = 1; for n > 1, a(n) is the smallest number > a(n-1) such that a(1) + a(2) + ... + a(n) is a composite number.
1, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70
Offset: 1
Examples
The third term is 4 because 1+3+4=8 is composite.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
- Index entries for linear recurrences with constant coefficients, signature (2,-1).
Programs
-
Mathematica
p=1; lst={p}; Do[If[!PrimeQ[p+n], AppendTo[lst, n]; p=p+n], {n, 3, 70}]; lst nxt[{c_,a_}]:=Module[{k=a+1},While[!CompositeQ[c+k],k++];{c+k,k}]; NestList[nxt,{1,1},70][[;;,2]] (* Harvey P. Dale, Dec 05 2023 *)
Formula
From Chai Wah Wu, Jan 28 2024: (Start)
a(n) = 2*a(n-1) - a(n-2) for n > 7.
G.f.: x*(-x^6 + x^5 - x^4 + x^3 - x^2 + x + 1)/(x - 1)^2. (End)
Comments