login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A348056 Numbers k where the d(j)-th digit is j for d(j) and j > 0 and d(j) = 0 if and only if j is not a digit of k. 3

%I #32 Oct 21 2021 01:38:36

%S 0,1,10,12,21,100,103,120,123,132,210,213,301,321,1000,1004,1030,1034,

%T 1043,1200,1204,1230,1234,1243,1320,1324,1402,1432,2100,2104,2130,

%U 2134,2143,3010,3014,3210,3214,3412,4001,4031,4201,4231,4321,10000,10005,10040,10045,10054,10300,10305,10340,10345,10354,10430,10435,10503,10543

%N Numbers k where the d(j)-th digit is j for d(j) and j > 0 and d(j) = 0 if and only if j is not a digit of k.

%C Sequence consists of the numbers in which, for each j in 1..N (where N is the number of digits), j is the j-th digit, or is the k-th digit where k is the j-th digit, or is 0.

%C Equivalently, numbers that can be obtained from the number 1234..N (where N is the number of digits) by swapping the positions of zero or more pairs of digits and replacing zero or more unswapped digits with 0's. (Leading zeros are not allowed, so the '1' cannot be replaced with a 0.)

%C The maximum number of digits N is 9.

%C The last term is 987654321.

%C From _Michael S. Branicky_, Sep 26 2021: (Start)

%C The sequence has 29186 terms with <= 9 digits.

%C If a(n) is a term, then so is 10*a(n), up to the digit limit.

%C Terms with a higher number of digits could satisfy the property if d(j) = 0 for j >= 10. (End)

%H Michael S. Branicky, <a href="/A348056/a348056.txt">Python program for complete sequence</a>

%e 103 is a term, 1 is the 1st digit, 3 is the 3rd digit, and there is no digit 2, so the 2nd digit is 0.

%e 1 2 3

%e | . |

%e | . |

%e 1 0 3

%e 2143 is a term, 1 and 2 are the 2nd and 1st digits, respectively, and 3 and 4 are the 4th and 3rd digits, respectively.

%e 1 2 3 4

%e \ / \ /

%e X X

%e / \ / \

%e 2 1 4 3

%e 146203 is a term, 1 is the 1st digit, 2 and 4 are the 4th and 2nd digits, respectively, 3 and 6 are the 6th and 3rd digits, respectively, and there is no digit 5, so the 5th digit is a 0:

%e 1 2 3 4 5 6

%e | \ \ / . /

%e | \ X__ __/

%e | \ / \ /.

%e | X X .

%e | / \ __/ \__

%e | / X . \

%e | / / \ . \

%e 1 4 6 2 0 3

%e .

%e 1 2 3 4 5 6 digit positions

%e term = 1 4 6 2 0 3

%e ^-----^ 2,4 swapped

%e ^--------^ 3,6 swapped

%t q[n_] := Module[{d = IntegerDigits[n], nd}, nd = Length[d]; AllTrue[Range[nd], d[[#]] == 0 || (d[[#]] <= nd && d[[d[[#]]]] == # ) &]]; Select[Range[0, 13245], q] (* _Amiram Eldar_, Sep 26 2021 *)

%o (Python) # see links for faster version generating entire sequence

%o def ok(n):

%o digs = str(n)

%o if int(max(digs)) > len(digs): return False

%o for j, dj in enumerate(digs, start=1):

%o if dj != '0' and digs[int(dj)-1] != str(j): return False

%o return True

%o print(list(filter(ok, range(100001)))) # _Michael S. Branicky_, Sep 26 2021

%Y Primes are in A346499.

%K nonn,base,fini

%O 1,3

%A _Rodolfo Kurchan_, Sep 26 2021

%E More terms added by _Claudio Meller_, Sep 26 2021

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 16:40 EDT 2024. Contains 371916 sequences. (Running on oeis4.)