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.

A268605 a(1) = 0; a(n+1) is the smallest integer in which the difference between its digits sum and the a(n) digits sum is equal to the n-th prime.

Original entry on oeis.org

0, 2, 5, 19, 89, 1999, 59999, 4999999, 599999999, 199999999999, 399999999999999, 799999999999999999, 8999999999999999999999, 499999999999999999999999999, 29999999999999999999999999999999, 4999999999999999999999999999999999999
Offset: 1

Views

Author

Francesco Di Matteo, Feb 17 2016

Keywords

Comments

First 8 terms are primes (and are also in A061248). Next terms are not always primes.

Examples

			a(4) = 19 and 1 + 9 = 10; so a(5) = 89 because 8 + 9 = 17 and 17 - 10 = 7, that is the 4th prime.
		

Crossrefs

Programs

  • PARI
    findnext(x, k) = {sx = sumdigits(x); pk = prime(k); y = 1; while (sumdigits(y) - sx != pk, y++); y;}
    lista(nn) = {print1(x = 0, ", "); for (k=1, nn, y = findnext(x, k); print1(y, ", "); x = y;);} \\ Michel Marcus, Feb 19 2016
  • Python
    sumprime = 0
    isPrime=lambda x: all(x % i != 0 for i in range(int(x**0.5)+1)[2:])
    print(0)
    for i in range(2,100):
      if isPrime(i):
        alfa = ""
        k = i + sumprime
        sumprime = k
        while k > 9:
          alfa = alfa + "9"
          k = k - 9
        alfa = str(k)+alfa
        print(alfa)
    

Formula

a(n) = A051885( A007504(n-1) ). - R. J. Mathar, Jun 19 2021

Extensions

NAME adapted to offset by R. J. Mathar, Jun 19 2021