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

A379749 a(n) is the first prime that has digit sum n in base n and n+1 in base n+1.

Original entry on oeis.org

5, 7, 13, 41, 31, 43, 113, 73, 181, 331, 397, 157, 547, 211, 241, 1361, 307, 2053, 761, 421, 463, 1013, 1657, 601, 1301, 3511, 757, 2437, 1741, 1861, 5953, 2113, 1123, 2381, 2521, 6661, 4219, 1483, 3121, 13121, 1723, 3613, 9461, 9901, 6211, 12973, 4513, 7057, 7351, 2551, 15913, 8269, 25759, 2971
Offset: 2

Views

Author

Robert Israel, Jan 01 2025

Keywords

Comments

For n >= 3, the least number with digit sum n in base n and n+1 in base n+1 is A002061(n) = n^2 - n + 1. This is prime for n in A055494. Thus (if it exists) a(n) >= A002061(n), with equality for n in A055494.

Examples

			For n = 8, a(8) = 113 because 113 is prime, 113 = 161_8 = 135_9 has digit sums 8 in base 8 and 9 in base 9, and no smaller prime works.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local k,v,x;
      for k from 1 do
        v:= convert(convert(k,base,n),`+`);
        if v <= n then
          x:= k*n + n-v;
          if convert(convert(x,base,n+1),`+`) = n+1 and isprime(x) then return x fi
        fi
      od;
    end proc:
    map(f, [$2 .. 100]);
  • Mathematica
    a[n_]:=Module[{k=1}, While[DigitSum[Prime[k],n]!=n || DigitSum[Prime[k],n+1]!=n+1, k++]; Prime[k]]; Array[a,54,2] (* Stefano Spezia, Jan 01 2025 *)
  • PARI
    a(n) = my(p=2); while ((sumdigits(p, n) != n) || (sumdigits(p, n+1) != n+1), p=nextprime(p+1)); p; \\ Michel Marcus, Jan 02 2025
    
  • Python
    from sympy import isprime
    from sympy.ntheory import digits
    def nextsod(n, base):
        c, b, w = 0, base, 0
        while True:
            d = n%b
            if d+1 < b and c:
                return (n+1)*b**w + ((c-1)%(b-1)+1)*b**((c-1)//(b-1))-1
            c += d; n //= b; w += 1
    def A226636gen(sod=3, base=3): # generator of terms for any sod, base
        an = (sod%(base-1)+1)*base**(sod//(base-1))-1
        while True: yield an; an = nextsod(an, base)
    def a(n):
        for k in A226636gen(sod=n, base=n):
            if sum(digits(k, n+1)[1:]) == n+1 and isprime(k):
                return k
    print([a(n) for n in range(2, 56)]) # Michael S. Branicky, Jan 04 2025
Showing 1-1 of 1 results.