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.

A131097 Sum of digits of 3-smooth numbers in ternary representation.

Original entry on oeis.org

1, 2, 1, 2, 2, 4, 1, 2, 4, 2, 4, 1, 4, 2, 4, 2, 4, 4, 1, 4, 2, 6, 4, 2, 4, 4, 1, 4, 4, 2, 6, 4, 2, 8, 4, 4, 1, 4, 4, 2, 8, 6, 4, 2, 8, 4, 4, 10, 1, 4, 4, 2, 8, 6, 4, 10, 2, 8, 4, 4, 10, 1, 4, 4, 8, 2, 8, 6, 4, 10, 2, 8, 4, 10, 4, 10, 1, 4, 4, 8, 2, 8, 6, 16, 4, 10, 2, 8, 4, 10, 4
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 14 2007

Keywords

Comments

a(n) = A053735(A003586(n)); values are even iff greater than 1.

Programs

  • Maple
    Res:= NULL: N:= 10^6:
    for a from 0 to ilog2(N) do
      for b from 0 do
        v:= 2^a*3^b;
        if v > N then break fi;
        Res:= Res, v;
    od od:
    TS:= sort([Res]):
    map(t -> convert(convert(t,base,3),`+`), TS); # Robert Israel, Oct 08 2018
  • Python
    from sympy import integer_log
    from sympy.ntheory import digits
    def A131097(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x-sum((x//3**i).bit_length() for i in range(integer_log(x,3)[0]+1))
        return sum(digits(bisection(f,n,n),3)[1:]) # Chai Wah Wu, Jan 31 2025