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.

A320775 a(n) is the least exponent k greater than 1 such that prime(n)^k starts and ends in prime(n).

Original entry on oeis.org

21, 41, 24, 33, 171, 361, 461, 471, 1281, 1091, 231, 221, 236, 61, 861, 2761, 241, 546, 3261, 1991, 6081, 421, 9541, 5731, 4461, 1621, 21501, 10381, 5051, 1301, 16301, 30051, 18601, 13601, 3171, 8991, 7561, 3201, 33501, 8701, 17351, 5601, 13551, 901, 10301, 871
Offset: 1

Views

Author

Paolo P. Lava, Dec 03 2018

Keywords

Comments

a(n) always exists. Let p be a prime other than 2 or 5, and m its length in base 10. Let r be the multiplicative order of p mod 10^m. Then p^k ends in p if and only if k-1 is a multiple of r. p^(j*r+1) starts with p if and only if for some integer s, s + log_10(p)) <= (j*r+1)*log_10(p) < s + frac(log_10(p+1)). This is true for some j because r*log_10(p) is irrational and the fractional parts of the multiples of an irrational number are dense in [0,1]. - Robert Israel, Dec 12 2018
If all integers are considered instead of only primes, not all of them can satisfy the requirement. For instance see A075823 for two digits numbers.
Record values beyond 10^5 are: a(51) = 138801, a(74) = 193701, a(88) = 1766101. Also, a(98) = 282076 and a(100) = 438501 would be record values if not preceded by a(88). - M. F. Hasler, Dec 14 2018

Examples

			2^21 = 2097152 and 21 is the least exponent;
3^41 = 36472996377170786403 and 41 is the least exponent.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local p, k,m,q,r;
      p:= ithprime(n);
      m:= ilog10(p)+1;
      q:= numtheory:-order(p,10^m);
      for k from q+1 by q do
        r:= p^k;
        if p = floor(r/10^(ilog10(r)+1-m))
          then return k
        fi;
      od
    end proc:
    f(1):= 21: f(3):= 24:
    map(f, [$1..50]); # Robert Israel, Dec 12 2018
  • Mathematica
    a[p_] := Module[{d=IntegerDigits[p]}, nd=Length[d];k=2; While[IntegerDigits[p^k][[1;;nd]] != d || IntegerDigits[p^k][[-nd;;-1]] != d, k++]; k]; a/@Prime@Range@10 (* Amiram Eldar, Dec 10 2018 *)
  • PARI
    isokd(d, dpk) = {for (i=1, #d, if (dpk[i] != d[i], return (0));); return (1);}
    isok(p, k) = {my(dpk=digits(p^k), d = digits(p)); if (!isokd(d, dpk), return (0)); isokd(Vecrev(d), Vecrev(dpk));}
    a(n) = {my(k=2, p = prime(n)); while (!isok(p, k), k++); k;} \\ Michel Marcus, Dec 10 2018
    
  • PARI
    apply( {A320775(n, d=logint(n=prime(n), 10)+1, K=if(n>5||n==3,znorder(Mod(n, 10^d)),n+18), f(x)=x\10^(logint(x, 10)+1-d))=forstep(k=1+K,oo,K, n==f(n^k)&&return(k))}, [1..20]) \\ Define A320775 & test it via apply(). - M. F. Hasler, Dec 10 2018