|
|
A262356
|
|
a(1) = 1; for n > 1, let s denote the digit-string of a(n-1) with the first digit omitted. Then a(n) is the smallest number not yet present which starts with s, omitting leading zeros.
|
|
9
|
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 20, 13, 30, 14, 40, 15, 50, 16, 60, 17, 70, 18, 80, 19, 90, 21, 100, 22, 23, 31, 101, 102, 24, 41, 103, 32, 25, 51, 104, 42, 26, 61, 105, 52, 27, 71, 106, 62, 28, 81, 107, 72, 29, 91, 108, 82, 200, 33, 34, 43, 35, 53
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
A permutation of the positive integers with inverse A262358;
It seems clear that every number will appear, but it would be nice to have a formal proof. - N. J. A. Sloane, Sep 20 2015
|
|
LINKS
|
|
|
MATHEMATICA
|
a[1] = 1; a[n_] := a[n] = Module[{s, k}, s = Rest[IntegerDigits[a[n - 1]]] //. {(0).., d__} :> {d}; For[k = 2, True, k++, If[FreeQ[Array[a, n - 1], k], If[s == {0}, Return[k], If[IntegerDigits[k][[1 ;; Length[s]]] == s, Return[k]]]]]];
|
|
PROG
|
(Haskell)
import Data.List (isPrefixOf, delete, genericIndex)
import Data.Set (singleton, notMember, insert)
a262356 n = a262356_list !! (n-1)
a262356_list = 1 : f "" (singleton "1") where
f xs s = (read ys :: Int) : f (dropWhile (== '0') ys') (insert ys s)
where ys@(_:ys') = head
[vs | vs <- zss, isPrefixOf xs vs, notMember vs s]
zss = map show [2..]
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|