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

A341702 a(n) is the smallest k < n such that the decimal concatenation n||n-1||n-2||...||n-k is prime, or -1 if no such prime exists.

Original entry on oeis.org

-1, -1, 0, 0, 1, 0, -1, 0, -1, -1, 1, 0, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, 1, 0, 1, 12, -1, 4, -1, 0, -1, 0, -1, -1, 1, -1, -1, 0, -1, -1, -1, 0, 1, 0, -1, -1, 7, 0, 7, -1, -1, 4, 15, 0, -1, 12, 9, -1, 1, 0, 13, 0, -1, -1, -1, -1, -1, 0, 57, -1, 1, 0, -1, 0
Offset: 0

Views

Author

Chai Wah Wu, Feb 23 2021

Keywords

Comments

A variation of A341716. a(n) = n-1 for n = 82. Are there other n such that a(n) = n-1?
Similar argument as in A341716 shows that if n > 3 and a(n) >= 0, then n-a(n) is odd, a(n) !== 2 (mod 3) and 2n-a(n) !== 0 (mod 3).

Examples

			a(10) = 1 since 109 is prime. a(22) = 1 since 2221 is prime.
		

Crossrefs

Programs

  • Maple
    tcat:= proc(x,y) x*10^(1+ilog10(y))+y end proc:
    f:= proc(n) local x,k;
      x:= n;
      for k from 0 to n-1 do
        if isprime(x) then return k fi;
        x:= tcat(x,n-k-1)
      od;
      -1
    end proc:
    map(f, [$0..100]); # Robert Israel, Mar 02 2022
  • PARI
    a(n) = my(k=0, s=Str(n)); while (!isprime(eval(s)), k++; n--; if (k>=n, return(-1)); s = concat(s, Str(n-k))); return(k); \\ Michel Marcus, Mar 02 2022
  • Python
    from sympy import isprime
    def A341702(n):
        k, m = n, n-1
        while not isprime(k) and m > 0:
            k = int(str(k)+str(m))
            m -= 1
        return n-m-1 if isprime(k) else -1
    

Formula

a(n) = n-A341701(n).
a(p) = 0 if and only if p is prime.

A341931 a(n) = smallest m > 0 such that the decimal concatenation n||n-1||n-2||...||m is prime, or -1 if no such prime exists.

Original entry on oeis.org

-1, -1, 2, 3, 3, 5, -1, 3, -1, -1, 7, 11, -1, 13, -1, -1, -1, 17, -1, 19, -1, -1, 19, 23, 23, 13, -1, 23, -1, 29, -1, 31, -1, -1, 33, -1, -1, 37, -1, -1, -1, 41, 41, 43, -1, -1, 3, 47, 17, -1, -1, 47, 37, 41, -1, 27, 47, -1, 57, 59, 47, 61, -1, -1, -1, -1, -1
Offset: 0

Views

Author

Chai Wah Wu, Feb 23 2021

Keywords

Comments

a(n) <= A341701(n). a(82) = 1, are there any other n such that a(n) = 1?
Primes p such that a(p) < p: 7, 53, 73, 79, 89, 103, ...
n such that a(n) < A341701(n): 7, 10, 22, 46, 48, 53, 55, 73, ...
Similar argument as in A341716 shows that if n > 3 and a(n) >= 0, then a(n) is odd, n-a(n) !== 2 (mod 3) and n+a(n) !== 0 (mod 3).

Examples

			a(7) = 3 since 76543 is prime and 765432, 7654321 are not. a(10) = 7 since 10987 is prime.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def A341931(n):
        k, m, r = n, n-1, n if isprime(n) else -1
        while m > 0:
            k = int(str(k)+str(m))
            if isprime(k):
                r = m
            m -= 1
        return r

A341932 a(n) = largest k < n such that the decimal concatenation n||n-1||n-2||...||n-k is prime, or -1 if no such prime exists.

Original entry on oeis.org

-1, -1, 0, 0, 1, 0, -1, 4, -1, -1, 3, 0, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, 3, 0, 1, 12, -1, 4, -1, 0, -1, 0, -1, -1, 1, -1, -1, 0, -1, -1, -1, 0, 1, 0, -1, -1, 43, 0, 31, -1, -1, 4, 15, 12, -1, 28, 9, -1, 1, 0, 13, 0, -1, -1, -1, -1, -1, 0, 57, -1, 1, 0, -1
Offset: 0

Views

Author

Chai Wah Wu, Feb 23 2021

Keywords

Comments

a(82) = 81, are there any other n such that a(n) = n-1?
Primes p such that a(p) > 0: 7, 53, 73, 79, 89, 103, ...
n such that a(n) > A341702(n): 7, 10, 22, 46, 48, 53, 55, 73, ...
Similar argument as in A341716 shows that if n > 3 and a(n) >= 0, then n-a(n) is odd, a(n) !== 2 (mod 3) and 2n-a(n) !== 0 (mod 3).

Examples

			a(22) = 3 since 22212019 is prime.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def A341932(n):
        k, m, r = n, n-1, 0 if isprime(n) else -1
        while m > 0:
            k = int(str(k)+str(m))
            if isprime(k):
                r = n-m
            m -= 1
        return r

Formula

a(n) = n-A341931(n) >= A341702(n).
Showing 1-3 of 3 results.