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.

A355035 Consider the least base b >= 2 where the sum of digits of n is a prime number; a(n) corresponds to this prime number.

Original entry on oeis.org

2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 5, 2, 3, 3, 3, 3, 3, 2, 5, 2, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 5, 3, 3, 7, 5, 2, 3, 3, 5, 3, 7, 2, 5, 3, 3, 7, 5, 5, 5, 5, 3, 13, 2, 2, 3, 2, 3, 3, 7, 2, 3, 3, 5, 3, 7, 3, 5, 2, 3, 3, 3, 3, 3, 5, 5, 3
Offset: 2

Views

Author

Rémy Sigrist, Jun 16 2022

Keywords

Examples

			For n = 16:
- we have the following expansions and sum of digits:
     b  16_b     Sum of digits in base b
     -  -------  -----------------------
     2  "10000"                        1
     3    "121"                        4
     4    "100"                        1
     5     "31"                        4
     6     "24"                        6
     7     "22"                        4
     8     "20"                        2
- so a(16) = 2.
		

Crossrefs

Cf. A216789, A355034 (corresponding b's).

Programs

  • PARI
    a(n) = my (s); for (b=2, oo, if (isprime(s=sumdigits(n,b)), return (s)))
    
  • Python
    from sympy import isprime
    from sympy.ntheory.digits import digits
    def s(n, b): return sum(digits(n, b)[1:])
    def a(n):
        b = 2
        while not isprime(s(n, b)): b += 1
        return s(n, b)
    print([a(n) for n in range(2, 89)]) # Michael S. Branicky, Jun 16 2022

Formula

a(n) = A216789(n, A355034(n)).