A203069 Lexicographically earliest sequence of distinct positive numbers such that a(n-1)+a(n) is odd and composite.
1, 8, 7, 2, 13, 12, 3, 6, 9, 16, 5, 4, 11, 10, 15, 18, 17, 22, 23, 26, 19, 14, 21, 24, 25, 20, 29, 28, 27, 30, 33, 32, 31, 34, 35, 40, 37, 38, 39, 36, 41, 44, 43, 42, 45, 46, 47, 48, 51, 54, 57, 58, 53, 52, 59, 56, 49, 50, 55, 60, 61, 62, 63, 66, 67, 68, 65
Offset: 1
Keywords
Examples
a(1)=1; the smallest possible even number m such that 1+m is composite is m=8, hence a(2)=8; the smallest possible odd number m such that 8+m is composite is m=7, hence a(3)=7; the smallest possible even number m such that 7+m is composite is m=2, hence a(4)=2.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Éric Angelini, A December quiz with a non-prime array, SeqFan list, Dec 28 2011.
- N. J. A. Sloane, Table of n, a(n) for n = 1..100000
- N. J. A. Sloane, Maple program
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Haskell
import Data.List (delete) a203069 n = a203069_list !! (n-1) a203069_list = 1 : f 1 [2..] where f u vs = g vs where g (w:ws) | odd z && a010051' z == 0 = w : f w (delete w vs) | otherwise = g ws where z = u + w -- Reinhard Zumkeller, Jan 14 2015
-
Maple
(See link)
-
Mathematica
Clear[used];used={1};oc[n_]:=Module[{k=If[OddQ[n],2,1]},While[ !CompositeQ[ n+k]||MemberQ[used,k],k+=2];Flatten[AppendTo[used,k]];k] (* Harvey P. Dale, Aug 16 2021 *)
-
Sage
@cached_function def A203069(n): if n == 1: return 1 used = set(A203069(i) for i in [1..n-1]) works = lambda an: (A203069(n-1)+an) % 2 == 1 and len(divisors((A203069(n-1)+an))) > 2 return next(k for k in PositiveIntegers() if k not in used and works(k)) # D. S. McNeil, Dec 28 2011
Extensions
Revised by N. J. A. Sloane, Aug 15 2021 at the suggestion of Harvey P. Dale.
Comments