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 11-12 of 12 results.

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

A217114 Greatest number (in decimal representation) with n nonprime substrings in base-4 representation (substrings with leading zeros are considered to be nonprime).

Original entry on oeis.org

11, 59, 239, 251, 751, 1007, 1019, 3823, 4079, 4055, 16111, 16087, 16319, 16367, 48991, 64351, 65263, 65269, 65471, 253919, 260959, 261079, 261847, 261871, 916319, 1043839, 1047391, 1044463, 1047511, 3665279, 3140991, 4189567, 4118519, 4177759, 4189565, 4193239, 14661117
Offset: 0

Views

Author

Hieronymus Fischer, Dec 20 2012

Keywords

Comments

The sequence is well-defined in that for each n the set of numbers with n nonprime substrings is not empty and finite. Proof of existence: Define m(n):=2*sum_{j=i..k} 4^j, where k:=floor((sqrt(8n+1)-1)/2), i:= n-(k(k+1)/2). For n=0,1,2,3,... the m(n) in base-4 representation are 2, 22, 20, 222, 220, 200, 2222, 2220, 2200, 2000, 22222, 22220, .... m(n) has k+1 digits and (k-i+1) 2’s. Thus, the number of nonprime substrings of m(n) is ((k+1)(k+2)/2)-k-1+i=(k(k+1)/2)+i=n. This proves the statement of existence. Proof of finiteness: Each 3-digit base-4 number has at least 1 nonprime substring. Hence, each 3(n+1)-digit number has at least n+1 nonprime substrings. Consequently, there is a boundary b < 4^(3n+2) such that all numbers > b have more than n nonprime substrings. It follows, that the set of numbers with n nonprime substrings is finite.

Examples

			a(0) = 11, since 11 = 23_4 (base-4) is the greatest number with zero nonprime substrings in base-4 representation.
a(1) = 59 = 323_4 has 6 substrings in base-4 representation (2, 3, 3, 23, 32 and 323), only 32_4=14 is a nonprime substring. 59 is the greatest such number with 1 nonprime substring.
a(2) = 239 = 3233_4 has 10 substrings in base-4 representation (2, 3, 3, 23, 32, 323, 233 and 3233), exactly 2 of them are nonprime substrings (32_4=14 and 33_4=15), and there is no greater number with 2 nonprime substrings in base-4 representation.
a(11) = 16087 = 3323113_4 has 28 substrings in base-4 representation. The base-4 nonprime substrings are 1, 1, 32, 33, 231, 332, 3113, 3231, 32311, 33321 and 323113. There is no greater number with 11 nonprime substrings in base-4 representation.
		

Crossrefs

Formula

a(n) >= A217104(n).
a(n) >= A217304(A000217(A110591(a(n)))-n).
a(n) <= 4^(n+2).
a(n) <= 4^min((n + 6)/2, 9*floor((n+18)/19)).
a(n) <= 64*4^(n/2).
a(n+m+1) >= 4*a(n), where m := floor(log_4(a(n))) + 1.
Previous Showing 11-12 of 12 results.