OFFSET
0,2
LINKS
N. J. A. Sloane and Reinhard Zumkeller, Table of n, a(n) for n = 0..10000 (terms 1..1594 from N. J. A. Sloane)
MATHEMATICA
nmax = 100;
seq[m_] := seq[m] = Module[{b, last}, b[_] = 0; last[_] = -1; last[0] = 2; nxt = 1; Do[hist = last[nxt]; b[n] = nxt; last[nxt] = n; nxt = 0; If[hist > 0, nxt = n - hist], {n, 3, m}];
A171862 = Array[b, m];
a[n_] := FirstPosition[A171862, n];
Table[a[n], {n, 0, nmax}] /. Missing["NotFound"] -> 0 // Flatten
];
seq[m = nmax];
seq[m = 2 m];
While[Print["m = ", m]; seq[m] != seq[m/2], m = 2 m; ];
seq[m] (* Jean-François Alcover, Aug 02 2018, borrowing some Maple code from N. J. A. Sloane *)
PROG
(Haskell)
import Data.List (elemIndex)
import Data.Maybe (fromJust)
a171862 n = 1 + fromJust (elemIndex n a181391_list)
-- Reinhard Zumkeller, Oct 31 2011
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 17 2010
EXTENSIONS
Offset corrected by Reinhard Zumkeller, Oct 31 2011
STATUS
approved