A045781 Erroneous version of A045670.
1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5
Offset: 1
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
Positive numbers may not start with 0 in the OEIS, otherwise this sequence would have been written as: 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 00000, 00001, 00010, 00011, 00100, 00101, 00110, 00111, 01000, 01001, 01010, 01011, ... From _Hieronymus Fischer_, Jun 06 2012: (Start) a(10) = 122. a(100) = 211212. a(10^3) = 222212112. a(10^4) = 1122211121112. a(10^5) = 2111122121211112. a(10^6) = 2221211112112111112. a(10^7) = 11221112112122121111112. a(10^8) = 12222212122221111211111112. a(10^9) = 22122211221212211212111111112. (End)
a007931 n = f (n + 1) where f x = if x < 2 then 0 else (10 * f x') + m + 1 where (x', m) = divMod x 2 -- Reinhard Zumkeller, Oct 26 2012
[n: n in [1..100000] | Set(Intseq(n)) subset {1,2}]; // Vincenzo Librandi, Aug 19 2016
# Maple program to produce the sequence: a:= proc(n) local m, r, d; m, r:= n, 0; while m>0 do d:= irem(m, 2, 'm'); if d=0 then d:=2; m:= m-1 fi; r:= d, r od; parse(cat(r))/10 end: seq(a(n), n=1..100); # Alois P. Heinz, Aug 26 2016 # Maple program to invert this sequence: given a(n), it returns n. - N. J. A. Sloane, Jul 09 2012 invert7931:=proc(u) local t1,t2,i; t1:=convert(u,base,10); [seq(t1[i]-1,i=1..nops(t1))]; [op(%),1]; t2:=convert(%,base,2,10); add(t2[i]*10^(i-1),i=1..nops(t2))-1; end;
f[n_] := FromDigits[Rest@IntegerDigits[n + 1, 2] + 1]; Array[f, 42] (* Robert G. Wilson v Sep 14 2006 *) (* Next, A007931 using (0,1) instead of (1,2) *) d[n_] := FromDigits[Rest@IntegerDigits[n + 1, 2] + 1]; Array[FromCharacterCode[ToCharacterCode[ToString[d[#]]] - 1] &, 100] (* Peter J. C. Moses, at request of Clark Kimberling, Feb 09 2012 *) Flatten[Table[FromDigits/@Tuples[{1,2},n],{n,5}]] (* Harvey P. Dale, Sep 13 2014 *)
apply( {A007931(n)=fromdigits([d+1|d<-binary(n+1)[^1]])}, [1..44]) \\ M. F. Hasler, Nov 03 2020, replacing older code from Mar 26 2015
/* inverse function */ apply( {A007931_inv(N)=fromdigits([d-1|d<-digits(N)],2)+2<M. F. Hasler, Nov 09 2020
def a(n): return int(bin(n+1)[3:].replace('1', '2').replace('0', '1')) print([a(n) for n in range(1, 45)]) # Michael S. Branicky, May 13 2021
def A007931(n): return int(s:=bin(n+1)[3:])+(10**(len(s))-1)//9 # Chai Wah Wu, Jun 13 2025
Comments