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!)
A290171 Numbers k such that (k-1)^2 < (k-1)! mod k^2. 0
5, 13, 563, 1277, 780887 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

The Wilson primes (A007540) are terms of this sequence.

a(n) is prime or twice a prime. Otherwise (k-1)! mod k^2 = 0 for k > 9 where k is not a prime and not twice a prime. - David A. Corneth, Jul 23 2017

LINKS

Table of n, a(n) for n=1..5.

MATHEMATICA

Select[Range[10^4], (#-1)^2<Mod[(#-1)!, #^2]&] (* Giorgos Kalogeropoulos, Jul 23 2021 *)

PROG

(PARI) for(n=1, 1e5, a=(n-1)!%n^2; if((n-1)^2<a, print1(n", ")))

(PARI) is(n) = (n-1)^2 < lift(Mod((n-1)!, n^2)) \\ Felix Fröhlich, Jul 23 2017

(PARI) val(n, p) = my(r=0); while(n, r+=n\=p); r

is(n) = my(f = factor(n), r = Mod(1, n^2)); if(#f~ > 2, return(0), if(#f~==2, if(f[1, 1]!=2, return(0)))); forprime(p=2, n-1, r*=Mod(p, n^2)^val(n-1, p)); (n-1)^2 < lift(r) \\ David A. Corneth, Jul 23 2017

(Python)

def ok(n):

    nn = n**2; f = 1%nn

    for k in range(1, n): f = f*k%nn

    return (n-1)**2 < f

print(list(filter(ok, range(1, 1300)))) # Michael S. Branicky, Jul 23 2021

(Python) # faster for initial segment of sequence

from math import factorial

def afind(limit, startk=1):

    k = startk; kkprev = (k-1)**2; f = factorial(k-1)

    while k < limit:

        kk = k*k

        if kkprev < f%kk: print(k, end=", ")

        kkprev = kk; f *= k; k += 1

afind(10000) # Michael S. Branicky, Jul 25 2021

CROSSREFS

Cf. A007540.

Sequence in context: A145557 A012033 A007540 * A157250 A009157 A153374

Adjacent sequences:  A290168 A290169 A290170 * A290172 A290173 A290174

KEYWORD

nonn,hard,more

AUTHOR

Gionata Neri, Jul 23 2017

EXTENSIONS

a(5) from Chai Wah Wu, Jul 30 2017

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 August 12 13:59 EDT 2022. Contains 356077 sequences. (Running on oeis4.)