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.

A290171 Numbers k such that (k-1)^2 < (k-1)! mod k^2.

Original entry on oeis.org

5, 13, 563, 1277, 780887
Offset: 1

Views

Author

Gionata Neri, Jul 23 2017

Keywords

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

Crossrefs

Cf. A007540.

Programs

  • Mathematica
    Select[Range[10^4],(#-1)^2Giorgos Kalogeropoulos, Jul 23 2021 *)
  • PARI
    for(n=1,1e5,a=(n-1)!%n^2;if((n-1)^2
    				
  • 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

Extensions

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