login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A109938 Largest k-digit prime == 1 (mod prime(n)) where k is the number of digits in prime(n), or 0 if no such prime exists. 2
7, 7, 0, 0, 89, 79, 0, 0, 47, 59, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 809, 619, 857, 0, 227, 509, 787, 823, 557, 0, 907, 0, 653, 0, 347, 359, 0, 383, 773, 0, 797, 0, 0, 0, 0, 467, 479, 0, 503, 0, 0, 0, 0, 0, 563, 0, 587, 0, 0, 0, 0, 0, 0, 0, 0, 0, 719, 0, 0, 0, 0, 0, 0, 0, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
EXAMPLE
a(13) = 83 as prime(13) = 41 and 83 == 1 (mod 41). 83 is the largest such two-digit prime.
MAPLE
A055642 := proc(n) max(1, ilog10(n)+1) ; end: A109938 := proc(n) local p, k, a; p := ithprime(n) ; k := A055642(p) ; a := 0; q := numtheory[pi](10^(k-1)) ; q := ithprime(q+1) ; while A055642(q) < k+1 do if q mod p = 1 and q > a then a := q ; fi ; q := nextprime(q) ; od ; RETURN(a) ; end: seq(A109938(n), n=1..90) ; # R. J. Mathar, Aug 17 2007
PROG
(Python)
from sympy import prime, prevprime
def a(n):
pn = prime(n); k = len(str(pn))
p = prevprime(10**k); lb = max(10**(k-1), 2)
while p > lb and p%pn != 1: p = prevprime(p)
return p if p > lb else 0
print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Jul 07 2021
(Python) # faster version for initial segment of sequence
from sympy import prime, primerange
def aupto(limit):
alst, primeswithkdigs, plimit = [], dict(), prime(limit)
for k in range(1, len(str(plimit))+1):
primeswithkdigs[k] = list(primerange(10**(k-1), 10**k))[::-1]
for pn in primerange(1, plimit+1):
k, found = len(str(pn)), False
for pk in primeswithkdigs[k]:
if pk%pn == 1: alst.append(pk); found = True; break
if not found: alst.append(0)
return alst
print(aupto(80)) # Michael S. Branicky, Jul 07 2021
CROSSREFS
Cf. A109939.
Sequence in context: A105167 A217227 A217346 * A372609 A215735 A344382
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Jul 19 2005
EXTENSIONS
More terms from R. J. Mathar, Aug 17 2007
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 23 02:22 EDT 2024. Contains 374544 sequences. (Running on oeis4.)