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-3 of 3 results.

A337496 Number of bases b for which the expansion of n in base b contains the largest digit possible (i.e., the digit b-1).

Original entry on oeis.org

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

Views

Author

François Marques, Aug 29 2020

Keywords

Comments

An integer b > 1 is a main base of n if n in base b contains the largest digit possible (i.e., the digit b-1).
2 is a main base for all nonzero integers because in binary, they start with the digit 1.
10 is a main base for all numbers with a 9 in their decimal expansion.
b = n+1 is a main base of n when n > 0.
A000005(n+1) - 1 <= a(n) <= ceiling(sqrt(n+1)) + floor(A000005(n+1)/2) - 1 for n > 0. Indeed, if b != 1 is a divisor of n+1 then n = (k-1)*b + b-1 so the last digit of n in base b is b-1. On the other side, n = q*b + r with r < b. So if b is a main base of n then either r = b-1 (and b is a divisor of n+1) or b is a main base of q and therefore b-1 <= q which implies (b-1)^2 < n (i.e., b <= floor(sqrt(n))+1 <= ceiling(sqrt(n+1)) ). But if b > sqrt(n+1) is a divisor of (n+1) then (n+1)/b < sqrt(n+1) is another divisors of n+1 and only half of them can be greater than its square root. - François Marques, Dec 07 2020

Examples

			For n = 7, a(7) = 4 because the main bases of 7 are 2, 3, 4 and 8 as shown in the table below:
          Base b |   2 |   3 |   4 |   5 |   6 |   7 |   8
-----------------+-----+-----+-----+-----+-----+-----+-----
     7 in base b | 111 |  21 |  13 |  12 |  11 |  10 |   7
-----------------+-----+-----+-----+-----+-----+-----+-----
b is a main base | yes | yes | yes |  no |  no |  no | yes
		

Crossrefs

Cf. A077268 (contains digit 0).

Programs

  • Maple
    A337496 := proc(n)
    local k, r:=0;
    for k from 2 to n+1 do
       if max(convert(n, base, k)) = k - 1 then
          r++;
       end if;
    end do;
    return r;
    end proc:
    seq(A337496(n), n=0..90);
  • Mathematica
    baseQ[n_, b_] := MemberQ[IntegerDigits[n, b], b - 1]; a[n_] := Count[Range[2, n + 1], ?(baseQ[n, #] &)]; Array[a, 100, 0] (* _Amiram Eldar, Sep 01 2020 *)
  • PARI
    a(n) = sum(b=2, n+1, vecmax(digits(n, b)) == b-1); \\ Michel Marcus, Aug 30 2020
    
  • PARI
    a337496(n) = my(last_pos(v,k) = forstep(j=#v, 1, -1, if(v[j]==k, return(#v-j))); return(-1);, s=ceil(sqrt(n+1)), p); (n==0) + 1 + sum(b=2, s, p=last_pos(digits(n,b), b-1); if(p<0,0, p==0,2, 1)) -((n+1)==s^2) -2*((n+1)==s*(s-1)); \\ François Marques, Dec 07 2020
    
  • Python
    def A337496(N):
        A337496_n=[0,1]
        for j in range(2,N+1):
            A337496_n.append(2)
        for b in range(3,((N+1)//2) +1):
            n=2*b-1
            while n<=N:
                s=0
                m=n//b
                while m%b==b-2:
                    s=s+1
                    m=m//b
                x=b*((b**s)-1)//(b-1)
                for i in range(n, min(N,x+n)+1):
                    A337496_n[i]+=1
                n=n+x+b
        return(A337496_n)
    print(A337496(100)) # Devansh Singh, Dec 30 2020

Formula

a(n) <= (n+1)/2 for n >= 3. - Devansh Singh, Sep 21 2020

Extensions

Minor edits by M. F. Hasler, Oct 26 2020

A077266 Triangle of number of zeros when n is written in base k (2 <= k <= n).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Nov 01 2002

Keywords

Examples

			Rows start:
  1;
  0,1;
  2,0,1;
  1,0,0,1;
  1,1,0,0,1;
  0,0,0,0,0,1;
  3,0,1,0,0,0,1;
  2,2,0,0,0,0,0,1;
  etc.
9 can be written in bases 2-9 as: 1001, 100, 21, 14, 13, 12, 11 and 10, in which case the numbers of zeros are 2,2,0,0,0,0,0,1.
		

Crossrefs

Columns include A023416 and A077267. Row sums are A033093, row maxima are A062842, number of positive terms in each row are A077268.

Programs

  • Mathematica
    Table[Count[#,0]&/@IntegerDigits[n,Range[2,n]],{n,2,15}]//Flatten (* Harvey P. Dale, Jun 02 2025 *)
  • PARI
    T(n, k) = #select(x->(x==0), digits(n, k));
    row(n) = vector(n-1, k, T(n,k+1));
    tabl(nn) = for (n=2, nn, print(row(n))); \\ Michel Marcus, Sep 02 2020

Formula

T(nk, k)=T(n, k)+1; T(nk+m, k)=T(n, k) if 0

A384436 a(n) is the number of distinct ways to represent n in any integer base >= 2 using only square digits.

Original entry on oeis.org

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

Author

Felix Huber, May 29 2025

Keywords

Comments

The representations of n remain the same for bases greater than n, as they all consist solely of the digit n.

Examples

			The a(36) = 11 distinct ways to represent 36 using only square digits are [1,0,0,1,0,0] in base 2, [1,1,0,0] in base 3, [1,0,0] in base 6, [4,4] in base 8, [4,0] in base 9, [1,16] in base 20, [1,9] in base 27, [1,4] in base 32, [1,1] in base 35, [1,0] in base 36 and [36] in bases >= 37.
		

Programs

  • Maple
    A384436:=proc(n)
        local a,b,c;
        a:=0;
        for b from 2 to n+1 do
            c:=convert(n,'base',b);
            if select(issqr,c)=c then
                a:=a+1
            fi
        od;
        return max(1,a)
    end proc;
    seq(A384436(n),n=0..81);
  • Mathematica
    a[n_] := Sum[Boole[AllTrue[IntegerDigits[n, b], IntegerQ[Sqrt[#]] &]], {b, 2, n+1}]; a[0] = 1; Array[a, 100, 0] (* Amiram Eldar, May 29 2025 *)
  • PARI
    a(n) = sum(b=2, n+1, my(d=digits(n,b)); #select(issquare, d) == #d); \\ Michel Marcus, May 29 2025

Formula

Trivial lower bound for n >= 2: a(n) >= 2 for nonsquares n and a(n) >= 3 for squares n because in base 2 the representations of n consists only of the square digits '0' and '1', in base n the representation of n is [1,0] and in bases > n the representation of n is [n].
Showing 1-3 of 3 results.