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.

A356553 For any n > 0, let b > 1 be the least base where the sum of digits of n divides n; a(n) is the sum of digits of n in base b.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 3, 1, 1, 2, 1, 2, 3, 2, 1, 2, 5, 2, 1, 2, 1, 2, 1, 1, 3, 2, 5, 2, 1, 2, 3, 2, 1, 3, 1, 4, 3, 2, 1, 2, 1, 5, 3, 4, 1, 2, 5, 4, 3, 2, 1, 4, 1, 2, 3, 1, 5, 2, 1, 2, 3, 10, 1, 2, 1, 2, 5, 4, 7, 6, 1, 2, 3, 2, 1, 3, 5, 2, 3
Offset: 1

Views

Author

Rémy Sigrist, Aug 12 2022

Keywords

Comments

See A356552 for the corresponding bases.

Examples

			For n = 14:
- we have:
      b   sum of digits  divides 14?
      --  -------------  -----------
       2              3  no
       3              4  no
       4              5  no
       5              6  no
       6              4  no
       7              2  yes
- so a(14) = 2.
		

Crossrefs

Cf. A356552.

Programs

  • Mathematica
    a[n_] := Module[{b = 2}, While[!Divisible[n, (s = Plus @@ IntegerDigits[n, b])], b++]; s]; Array[a, 100] (* Amiram Eldar, Sep 19 2022 *)
  • PARI
    a(n) = { for (b=2, oo, my (s=sumdigits(n, b)); if (n % s==0, return (s))) }
    
  • Python
    from sympy.ntheory import digits
    def a(n):
        b = 2
        while n != 0 and n%sum(digits(n, b)[1:]): b += 1
        return sum(digits(n, b)[1:])
    print([a(n) for n in range(1, 88)]) # Michael S. Branicky, Aug 12 2022