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.

Previous Showing 41-50 of 51 results. Next

A309954 Product of digits of (n written in base 4).

Original entry on oeis.org

0, 1, 2, 3, 0, 1, 2, 3, 0, 2, 4, 6, 0, 3, 6, 9, 0, 0, 0, 0, 0, 1, 2, 3, 0, 2, 4, 6, 0, 3, 6, 9, 0, 0, 0, 0, 0, 2, 4, 6, 0, 4, 8, 12, 0, 6, 12, 18, 0, 0, 0, 0, 0, 3, 6, 9, 0, 6, 12, 18, 0, 9, 18, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 2, 4, 6, 0, 3, 6, 9, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Ilya Gutkovskiy, Aug 24 2019

Keywords

Crossrefs

Programs

  • Mathematica
    Table[Times @@ IntegerDigits[n, 4], {n, 0, 100}]

Formula

G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2) * (1 + A(x^4)).

A216789 Table read by antidiagonals: T(n,k) is the digital sum of k in base n displayed in decimal.

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 0, 1, 2, 2, 0, 1, 2, 1, 1, 0, 1, 2, 3, 2, 2, 0, 1, 2, 3, 1, 3, 2, 0, 1, 2, 3, 4, 2, 2, 3, 0, 1, 2, 3, 4, 1, 3, 3, 1, 0, 1, 2, 3, 4, 5, 2, 4, 4, 2, 0, 1, 2, 3, 4, 5, 1, 3, 2, 1, 2, 0, 1, 2, 3, 4, 5, 6, 2, 4, 3, 2, 3
Offset: 2

Views

Author

Keywords

Comments

T(n,k) is the least number of powers of n that add up to k. - Mohammed Yaseen, Nov 12 2022

Examples

			A000120   0, 1, 1, 2, 1, 2, 2, 3, 1, 2,  2,  3,  2,  3,  3,  4, 1, 2, 2
A053735   0, 1, 2, 1, 2, 3, 2, 3, 4, 1,  2,  3,  2,  3,  4,  3, 4, 5, 2
A053737   0, 1, 2, 3, 1, 2, 3, 4, 2, 3,  4,  5,  3,  4,  5,  6, 1, 2, 3
A053824   0, 1, 2, 3, 4, 1, 2, 3, 4, 5,  2,  3,  4,  5,  6,  3, 4, 5, 6
A053827   0, 1, 2, 3, 4, 5, 1, 2, 3, 4,  5,  6,  2,  3,  4,  5, 6, 7, 3
A053828   0, 1, 2, 3, 4, 5, 6, 1, 2, 3,  4,  5,  6,  7,  2,  3, 4, 5, 6
A053829   0, 1, 2, 3, 4, 5, 6, 7, 1, 2,  3,  4,  5,  6,  7,  8, 2, 3, 4
A053830   0, 1, 2, 3, 4, 5, 6, 7, 8, 1,  2,  3,  4,  5,  6,  7, 8, 9, 2
A007953   0, 1, 2, 3, 4, 5, 6, 7, 8, 9,  1,  2,  3,  4,  5,  6, 7, 8, 9
A053831   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  1,  2,  3,  4,  5, 6, 7, 8
A053832   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,  1,  2,  3,  4, 5, 6, 7
A053833   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,  1,  2,  3, 4, 5, 6
A053834   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,  1,  2, 3, 4, 5
A053835   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,  1, 2, 3, 4
A053836   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3
		

Crossrefs

Programs

  • Maple
    [seq(seq(convert(convert(n-b,base,b),`+`),b=n..2,-1),n=1..15)]; # Robert Israel, Aug 02 2020
  • Mathematica
    DigitSum[n_, b_: 10] := Total[IntegerDigits[n, b]]; Table[ DigitSum[n - b, b], {n, 2, 13}, {b, n, 2, -1}] // Flatten

Extensions

Name and offset corrected by Mohammed Yaseen, Nov 12 2022

A260112 Minimal number of steps to get from 0 to n by (a) adding 1 or (b) multiplying by 4.

Original entry on oeis.org

0, 1, 2, 3, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10, 8, 9, 10, 11, 4, 5, 6, 7, 5, 6, 7, 8, 6, 7, 8, 9, 7, 8, 9, 10, 5, 6, 7, 8, 6
Offset: 0

Views

Author

Peter Kagey, Jul 16 2015

Keywords

Comments

a(n) = (Weight of quaternary expansion of n) + (length of quaternary expansion of n) - 1.

Examples

			For a(308) = 9, the nine steps are: 308 => 77 => 76 => 19 => 18 => 17 => 16 => 4 => 1 => 0.
		

Crossrefs

Analogous sequences with a different multiplier k: A056792 (k=2), A061282 (k=3).
Cf. A053737, A110591, A007090: base 4 sequences.

Programs

  • Haskell
    c i = if i `mod` 4 == 0 then i `div` 4 else i - 1
    b 0 foldCount = foldCount
    b sheetCount foldCount = b (c sheetCount) (foldCount + 1)
    a260112 n = b n 0 -- Peter Kagey, Sep 02 2015
  • Maple
    a:= n-> (l-> nops(l)+add(i, i=l)-1)(convert(n, base, 4)):
    seq(a(n), n=0..105);  # Alois P. Heinz, Jul 16 2015
  • PARI
    a(n)=sumdigits(n,4)+#digits(n,4)-1 \\ Charles R Greathouse IV, Jul 16 2015
    
  • Ruby
    def a(n); n.to_s(4).length + n.to_s(4).split('').map(&:to_i).reduce(:+) - 1 end
    

Formula

a(n) = A053737(n) + A110591(n) - 1. - Michel Marcus, Jul 17 2015

A334841 a(0) = 0; for n > 0, a(n) = (number of 1's and 3's in base 4 representation of n) - (number of 0's and 2's in base 4 representation of n).

Original entry on oeis.org

0, 1, -1, 1, 0, 2, 0, 2, -2, 0, -2, 0, 0, 2, 0, 2, -1, 1, -1, 1, 1, 3, 1, 3, -1, 1, -1, 1, 1, 3, 1, 3, -3, -1, -3, -1, -1, 1, -1, 1, -3, -1, -3, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 3, 1, 3, -1, 1, -1, 1, 1, 3, 1, 3, -2, 0, -2, 0, 0, 2, 0, 2, -2, 0, -2, 0, 0, 2, 0, 2, 0, 2, 0, 2, 2, 4, 2, 4, 0
Offset: 0

Views

Author

Keywords

Comments

Values are even for base 4 representations of n with an even number of digits, and odd for base 4 representations of n with an odd number of digits, except for a(0).

Examples

			      n in    #odd    #even
  n  base 4  digits - digits = a(n)
  =  ======  =======================
  0    0        0   -            0
  1    1        1   -    0   =   1
  2    2        0   -    1   =  -1
  3    3        1   -    0   =   1
  4   10        1   -    1   =   0
  5   11        2   -    0   =   2
  6   12        1   -    1   =   0
  7   13        2   -    0   =   2
		

Crossrefs

Programs

  • Maple
    a:= n-> `if`(n=0, 0, add(`if`(i in [1, 3], 1, -1), i=convert(n, base, 4))):
    seq(a(n), n=0..100);  # Alois P. Heinz, May 30 2020
  • Mathematica
    a[0] = 0; a[n_] := Total[-(-1)^(r = Range[0, 3]) * DigitCount[n, 4, r]]; Array[a, 100, 0] (* Amiram Eldar, May 13 2020 *)
    Join[{0},Table[Total[If[EvenQ[#],-1,1]&/@IntegerDigits[n,4]],{n,90}]] (* Harvey P. Dale, Sep 06 2020 *)
  • PARI
    a(n) = my(ret=0); if(n,forstep(i=0,logint(n,2),2, if(bittest(n,i),ret++,ret--))); ret; \\ Kevin Ryde, May 24 2020
    
  • Python
    import numpy as np
    def qnary(n):
        e = n//4
        q = n%4
        if n == 0 : return 0
        if e == 0 : return q
        if e != 0 : return np.append(qnary(e), q)
    m = 400
    v = [0]
    for i in range(1, m+1) :
        t = np.array(qnary(i))
        t[t%2 != 0] = 1
        t[t%2 == 0] = -1
        v = np.append(v, np.sum(t))
    
  • Python
    def A334841(n):
        return 2*bin(n)[-1:1:-2].count('1')-(len(bin(n))-1)//2 if n > 0 else 0 # Chai Wah Wu, Sep 03 2020
  • R
    qnary = function(n, e, q){
      e = floor(n/4)
      q = n%%4
      if(n == 0 ){return(0)}
      if(e == 0){return(q)}
      else{return(c(qnary(e), (q)))}
    }
    m = 400
    s = seq(2, m)
    v = c(0)
    for(i in s){
      x = qnary(i-1)
      x[which(x%%2!=0)] = 1
      x[which(x%%2==0)] = -1
      v[i] = sum(x)
    }
    

Formula

a(n) = 2*A139351(n) - A110591(n), n>0. - R. J. Mathar, Sep 02 2020

A355487 Bitwise XOR of the base-4 digits of n.

Original entry on oeis.org

0, 1, 2, 3, 1, 0, 3, 2, 2, 3, 0, 1, 3, 2, 1, 0, 1, 0, 3, 2, 0, 1, 2, 3, 3, 2, 1, 0, 2, 3, 0, 1, 2, 3, 0, 1, 3, 2, 1, 0, 0, 1, 2, 3, 1, 0, 3, 2, 3, 2, 1, 0, 2, 3, 0, 1, 1, 0, 3, 2, 0, 1, 2, 3, 1, 0, 3, 2, 0, 1, 2, 3, 3, 2, 1, 0, 2, 3, 0, 1, 0, 1, 2, 3, 1, 0, 3
Offset: 0

Views

Author

Kevin Ryde, Jul 04 2022

Keywords

Comments

Equivalently, the parity of the odd position 1-bits of n and the parity of the even position 1-bits of n, combined as a(n) = 2*A269723(n) + A341389(n).
In GF(2)[x] polynomials encoded as bits of an integer (least significant bit for the constant term), a(n) is remainder n mod x^2 + 1.

Examples

			n=35 has base-4 digits 203 so a(35) = 2 XOR 0 XOR 3 = 1.
		

Crossrefs

Cf. A030373 (base 4 digits), A003987 (XOR).
Cf. A353167 (indices of 0's).
Other digit operations: A053737 (sum), A309954 (product).

Programs

  • Mathematica
    a[n_] := BitXor @@ IntegerDigits[n, 4]; Array[a, 100, 0] (* Amiram Eldar, Jul 05 2022 *)
  • PARI
    a(n) = if(n==0,0, fold(bitxor,digits(n,4)));
    
  • Python
    from operator import xor
    from functools import reduce
    from sympy.ntheory import digits
    def a(n): return reduce(xor, digits(n, 4)[1:])
    print([a(n) for n in range(87)]) # Michael S. Branicky, Jul 05 2022

Formula

Fixed point of the morphism 0 -> 0,1; 1 -> 2,3; 2 -> 1,0; 3 -> 3,2 starting from 0.

A037316 Numbers whose base-4 and base-5 expansions have the same digit sum.

Original entry on oeis.org

1, 2, 3, 28, 29, 40, 41, 42, 43, 52, 53, 54, 76, 77, 78, 79, 90, 91, 100, 101, 102, 103, 115, 136, 137, 138, 139, 160, 161, 162, 163, 188, 189, 210, 211, 236, 237, 238, 239, 270, 271, 280, 281, 282, 283, 295, 305, 306, 307, 330, 331
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A053737 (base-4 sum of digits), A053824 (base-5 sum of digits).

Programs

  • Maple
    filter:= n -> convert(convert(n,base,4),`+`)=convert(convert(n,base,5),`+`):
    select(filter, [$1..1000]); # Robert Israel, Mar 11 2018
  • Mathematica
    Select[Range[400],Total[IntegerDigits[#,4]]==Total[IntegerDigits[#,5]]&] (* Harvey P. Dale, Sep 15 2018 *)
  • PARI
    isok(k) = sumdigits(k, 4) == sumdigits(k, 5); \\ Michel Marcus, Jun 02 2021

A135738 Least positive integer with even digit sum in bases 2..n.

Original entry on oeis.org

3, 6, 10, 10, 54, 54, 54, 54, 130, 130, 130, 130, 390, 390, 2000, 2000, 3238, 3238, 4080, 4080, 7326, 7326, 16584, 16584, 17310, 17310, 17310, 17310, 17310, 17310, 17310, 17310, 231000, 231000, 231000, 231000, 466352, 466352, 466352, 466352, 3020830
Offset: 2

Views

Author

M. F. Hasler, Dec 06 2007

Keywords

Comments

The sequence is obviously increasing. It seems that a(2n+1) = a(2n) for n > 1. Is there a simple proof? Is there a simple way to construct a(n)? Notice the pattern in base N, e.g., 130 = 10000010_2 = 11211_3 = 2002_4 = 1010_5 = 334_6 = 244_7 = 202_8 = 154_9 = 109_11 = {10}{10}_12 = {10}0_13.

Examples

			a(2)=3 since 1=1_2, 2=10_2, so 3=11_2 is the number > 0 with even digit sum (1+1) in base 2.
a(3)=6 since 4=100_2, 5=12_3, so 6=20_3=110_2 is the least N > 0 with even digit sum in base 2 and in base 3.
a(4)=a(5)=10=1010_2=101_3=22_4=20_5 is the least N > 0 having even digit sum in bases 2 through 4 and has so also in base 5.
		

Crossrefs

Programs

  • PARI
    digitsum(n,b=10,s)={n=[n];while(n=divrem(n[1],b),s+=n[2]);s}
    A135738(Bmax,n=1)={until(!n++,for(b=2,Bmax,digitsum(n,b)%2&next(2));return(n))} /* n-th element of the sequence */
    t=1;for(b=2,100,print(b,":",t=A135738(b,t))) /* display the list */

Extensions

Corrected example a(3)=5 to a(3)=6 David Yablon (davar55(AT)yahoo.com), Mar 19 2010

A269224 Factorial of the sum of digits of n in base 4.

Original entry on oeis.org

1, 1, 2, 6, 1, 2, 6, 24, 2, 6, 24, 120, 6, 24, 120, 720, 1, 2, 6, 24, 2, 6, 24, 120, 6, 24, 120, 720, 24, 120, 720, 5040, 2, 6, 24, 120, 6, 24, 120, 720, 24, 120, 720, 5040, 120, 720, 5040, 40320, 6, 24, 120, 720, 24, 120, 720, 5040, 120, 720, 5040, 40320, 720, 5040, 40320
Offset: 0

Views

Author

M. F. Hasler, Mar 15 2016

Keywords

Comments

See sequences A093659, A269223 and A269221 for the base 2, base 3 and base 10 analog.

Crossrefs

Programs

  • Mathematica
    Table[Total[IntegerDigits[n, 4]]!, {n, 0, 62}] (* Michael De Vlieger, Mar 15 2016 *)
  • PARI
    A269224(n)=sumdigits(n,4)! \\ sumdigits(.,4) requires version >= 2.7; see A053737 for a substitute.
    
  • PARI
    a(n) = vecsum(digits(n,4))!; \\ Michel Marcus, Mar 15 2016

Formula

a(n) = A000142(A053737(n)).

A333596 a(0) = 0; for n > 0, a(n) = a(n-1) + (number of 1's and 3's in base-4 representation of n) - (number of 0's and 2's in base-4 representation of n).

Original entry on oeis.org

0, 1, 0, 1, 1, 3, 3, 5, 3, 3, 1, 1, 1, 3, 3, 5, 4, 5, 4, 5, 6, 9, 10, 13, 12, 13, 12, 13, 14, 17, 18, 21, 18, 17, 14, 13, 12, 13, 12, 13, 10, 9, 6, 5, 4, 5, 4, 5, 4, 5, 4, 5, 6, 9, 10, 13, 12, 13, 12, 13, 14, 17, 18, 21, 19, 19, 17, 17, 17, 19, 19, 21, 19, 19
Offset: 0

Views

Author

Keywords

Comments

Local maxima values minus 1 are divisible by 4.
For a digit-wise recurrence, it's convenient to sum n terms so b(n) = a(n-1) = Sum_{i=0..n-1} A334841(i). Then b(4n+r) = 4*b(n) + r*A334841(n) + (1 if r even), for 0 <= r <= 3 and 4n+r >= 1. This is 4 copies of terms 0..n-1 and r copies of the following n. The new lowest digits cancel when r is odd, or net +1 when r is even. Repeatedly expanding gives the PARI code below. - Kevin Ryde, Jun 02 2020

Examples

			      n in    #odd    #even
  n  base 4  digits - digits + a(n-1) = a(n)
  =  ======  ===============================
  0    0        0   -                     0
  1    1        1   -    0   +    0   =   1
  2    2        0   -    1   +    1   =   0
  3    3        1   -    0   +    0   =   1
  4   10        1   -    1   +    1   =   1
  5   11        2   -    0   +    1   =   3
  6   12        1   -    1   +    3   =   3
  7   13        2   -    0   +    3   =   5
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0, a(n-1) +add(
         `if`(i in [1, 3], 1, -1), i=convert(n, base, 4)))
        end:
    seq(a(n), n=0..80);  # Alois P. Heinz, May 30 2020
  • Mathematica
    f[n_] := Total[(-1)^(r = Range[0, 3]) * DigitCount[n, 4, r]]; a[0] = 0; a[n_] := a[n] = a[n - 1] - f[n]; Array[a, 100, 0] (* Amiram Eldar, Apr 24 2020 *)
  • PARI
    a(n) = my(v=digits(n+1,4),s=0); for(i=1,#v, my(t=v[i]); v[i]=t*s+!(t%2); s-=(-1)^t); fromdigits(v,4); \\ Kevin Ryde, May 30 2020
    
  • PARI
    b(n)=my(d=digits(n,4)); -sum(i=1,#d,(-1)^d[i])
    first(n)=my(s); concat(0,vector(n,k,s+=b(k))) \\ Charles R Greathouse IV, Jul 04 2020
    
  • Python
    import numpy as np
    def qnary(n):
        e = n//4
        q = n%4
        if n == 0 : return 0
        if e == 0 : return q
        if e != 0 : return np.append(qnary(e), q)
    m = 400
    v = [0]
    for i in range(1,m+1) :
        t = np.array(qnary(i))
        t[t%2 != 0] = 1
        t[t%2 == 0] = -1
        v = np.append(v, np.sum([np.sum(t), v[i-1]]))
    
  • Python
    from itertools import accumulate
    def A334841(n):
        return 2*bin(n)[-1:1:-2].count('1')-(len(bin(n))-1)//2 if n > 0 else 0
    A333596_list = list(accumulate(A334841(n) for n in range(10000))) # Chai Wah Wu, Sep 03 2020
  • R
    qnary = function(n, e, q){
      e = floor(n/4)
      q = n%%4
      if(n == 0 ){return(0)}
      if(e == 0){return(q)}
      else{return(c(qnary(e), (q)))}
    }
    m = 400
    s = seq(2,m)
    v = c(0)
    for(i in s){
      x = qnary(i-1)
      x[which(x%%2!=0)] = 1
      x[which(x%%2==0)] = -1
      v[i] = sum(x,v[i-1])
    }
    

A037309 Numbers whose base-3 and base-4 expansions have the same digit sum.

Original entry on oeis.org

1, 2, 21, 22, 23, 33, 34, 35, 40, 41, 78, 79, 88, 89, 100, 101, 112, 113, 136, 137, 150, 151, 156, 157, 158, 188, 204, 205, 206, 210, 211, 228, 229, 230, 236, 261, 262, 263, 273, 274, 275, 280, 281, 294, 295, 312, 313, 314, 328
Offset: 1

Views

Author

Keywords

Formula

{n: A053735(n) = A053737(n).} - R. J. Mathar, Jun 30 2021
Previous Showing 41-50 of 51 results. Next