cp's OEIS Frontend

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.

Showing 1-2 of 2 results.

A048678 Binary expansion of nonnegative integers expanded to "Zeckendorffian format" with rewrite rules 0->0, 1->01.

Original entry on oeis.org

0, 1, 2, 5, 4, 9, 10, 21, 8, 17, 18, 37, 20, 41, 42, 85, 16, 33, 34, 69, 36, 73, 74, 149, 40, 81, 82, 165, 84, 169, 170, 341, 32, 65, 66, 133, 68, 137, 138, 277, 72, 145, 146, 293, 148, 297, 298, 597, 80, 161, 162, 325, 164, 329, 330, 661, 168, 337, 338, 677, 340
Offset: 0

Views

Author

Keywords

Comments

No two adjacent 1-bits. Permutation of A003714.
Replace 1 with 01 in binary. - Ralf Stephan, Oct 07 2003

Examples

			11=1011 in binary, thus is rewritten as 100101 = 37 in decimal.
		

Crossrefs

MASKTRANS transform of A053644.
Cf. A124108.

Programs

  • Haskell
    a048678 0 = 0
    a048678 x = 2 * (b + 1) * a048678 x' + b
                where (x', b) = divMod x 2
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Maple
    rewrite_0to0_1to01 := proc(n) option remember; if(n < 2) then RETURN(n); else RETURN(((2^(1+(n mod 2))) * rewrite_0to0_1to01(floor(n/2))) + (n mod 2)); fi; end;
  • Mathematica
    f[n_] := FromDigits[ Flatten[IntegerDigits[n, 2] /. {1 -> {0, 1}}], 2]; Table[f@n, {n, 0, 60}] (* Robert G. Wilson v, Dec 11 2009 *)
  • PARI
    a(n)=if(n<1,0,(3-(-1)^n)*a(floor(n/2))+(1-(-1)^n)/2)
    
  • PARI
    a(n) = if(n == 0, 0, my(A = -2); sum(i = 0, logint(n, 2), A++; if(bittest(n, i), 1 << (A++)))) \\ Mikhail Kurkov, Mar 14 2024
    
  • Python
    def a(n):
        return 0 if n==0 else (3 - (-1)**n)*a(n//2) + (1 - (-1)**n)//2
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 30 2017
    
  • Python
    def A048678(n): return int(bin(n)[2:].replace('1','01'),2) # Chai Wah Wu, Mar 18 2024

Formula

a(n) = rewrite_0to0_1to01(n) [ Each 0->1, 1->10 in binary expansion of n ].
a(0)=0; a(n) = (3-(-1)^n)*a(floor(n/2))+(1-(-1)^n)/2. - Benoit Cloitre, Aug 31 2003
a(0)=0, a(2n) = 2a(n), a(2n+1) = 4a(n) + 1. - Ralf Stephan, Oct 07 2003

A322131 In the decimal expansion of n, replace each digit d with 2*d.

Original entry on oeis.org

0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 210, 212, 214, 216, 218, 40, 42, 44, 46, 48, 410, 412, 414, 416, 418, 60, 62, 64, 66, 68, 610, 612, 614, 616, 618, 80, 82, 84, 86, 88, 810, 812, 814, 816, 818, 100, 102, 104, 106, 108, 1010, 1012, 1014
Offset: 0

Views

Author

Rémy Sigrist, Nov 27 2018

Keywords

Comments

This is an operation on digit strings: 1066 becomes 201212, for example. 86420 becomes 1612840. The result is always even - see A330336. - N. J. A. Sloane, Dec 17 2019
This sequence is a variant of A124108 in decimal base.

Examples

			For n = 109:
- we replace "1" with "2", "0" with "0" and "9" with "18",
- hence a(109) = 2018.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) option remember;
    local m,d;
    d:= n mod 10; m:= floor(n/10);
    if d >= 5 then 100*procname(m) + 2*d
    else 10*procname(m)+2*d
    fi
    end proc:
    f(0):= 0:
    map(f, [$0..100]); # Robert Israel, Nov 28 2018
  • Mathematica
    a[n_] := FromDigits@Flatten@IntegerDigits[2*IntegerDigits[n]]; Array[a, 60, 0] (* Amiram Eldar, Nov 28 2018 *)
  • PARI
    a(n, base=10) = my (d=digits(n, base), v=0); for (i=1, #d, v = v*base^max(1,#digits(2*d[i],base)) + 2*d[i]); v
    
  • Python
    def A322131(n):
       return int(''.join(str(int(d)*2) for d in str(n))) # Chai Wah Wu, Nov 29 2018

Formula

A061581(n+1) = a(A061581(n)).
A066686(a(n), a(k)) = a(A066686(n, k)) for any n > 0 and k > 0.
a(10*n + d) = 10*a(n) + 2*d for any n >= 0 and d = 0..4.
a(10*n + d) = 100*a(n) + 2*d for any n >= 0 and d = 5..9.
G.f. g(x) satisfies g(x) = (2*x + 4*x^2 + 6*x^3 + 8*x^4 + 10*x^5 + 12*x^6 + 14*x^7 + 16*x^8 + 18*x^9)/(1-x^10) + (10 + 10*x + 10*x^2 + 10*x^3 + 10*x^4 + 100*x^5 + 100*x^6 + 100*x^7 + 100*x^8 + 100*x^9)*g(x^10). - Robert Israel, Nov 28 2018
Showing 1-2 of 2 results.