OFFSET
1,2
COMMENTS
Inspired by an idea of Eric Angelini on the Sequence Fans list on Dec 28 2011.
Comments from N. J. A. Sloane, Aug 16 2021: (Start)
It is conjectured that this is a permutation of the positive integers. Is there a proof? The terms are distinct, by definition, and the sequence is clearly infinite. But does every number appear?
In the first 100000 terms, the only differences a(i)-a(i-1) that occur are -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11 (see A346610).
Also a(n) is surprisingly close to n - see A346611. (End)
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
EXAMPLE
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.
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 *)
PROG
(Sage)
@cached_function
def A203069(n):
if n == 1: return 1
used = set(A203069(i) for i in [1..n-1])
return next(k for k in PositiveIntegers() if k not in used and works(k)) # D. S. McNeil, Dec 28 2011
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Dec 28 2011
EXTENSIONS
Revised by N. J. A. Sloane, Aug 15 2021 at the suggestion of Harvey P. Dale.
STATUS
approved