login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A257231
a(n) = n^2 mod p where p is the least prime greater than n.
2
1, 1, 4, 1, 4, 1, 5, 9, 4, 1, 4, 1, 16, 9, 4, 1, 4, 1, 16, 9, 4, 1, 7, 25, 16, 9, 4, 1, 4, 1, 36, 25, 16, 9, 4, 1, 16, 9, 4, 1, 4, 1, 16, 9, 4, 1, 36, 25, 16, 9, 4, 1, 36, 25, 16, 9, 4, 1, 4, 1, 36, 25, 16, 9, 4, 1, 16, 9, 4, 1, 4, 1, 36, 25, 16, 9, 4, 1, 16, 9, 4, 1, 36, 25, 16, 9, 4
OFFSET
1,3
COMMENTS
Conjecture: a(n) is always a positive square, except for the terms 5, 7, 69, 42 and 17 given by n = 7, 23, 113, 114, and 115 respectively. It is easy to show that nonsquare terms are in [p, q) iff p and q are consecutive primes and q-p > sqrt(q). There are no gaps between consecutive primes greater than sqrt(q) for 127 < q < 4*10^18 (see Nicely's table of maximal prime gaps).
LINKS
Thomas R. Nicely, First occurrence prime gaps [For local copy see A000101]
Tomás Oliveira e Silva, Gaps between consecutive primes
EXAMPLE
a(23) = 7 because 23^2 mod 29 = 7.
a(24) = 25 because 24^2 mod 29 = 25.
MATHEMATICA
Table[Mod[n^2, NextPrime@ n], {n, 87}] (* Michael De Vlieger, Apr 19 2015 *)
Table[PowerMod[n, 2, NextPrime[n]], {n, 90}] (* Harvey P. Dale, May 24 2015 *)
PROG
(PARI) a(n)=n^2%nextprime(n+1)
(Magma) [n^2 mod NextPrime(n): n in [1..80]]; // Vincenzo Librandi, Apr 19 2015
CROSSREFS
Cf. A257230.
Sequence in context: A074393 A267633 A095666 * A196757 A193254 A193454
KEYWORD
nonn,easy
AUTHOR
Chris Boyd, Apr 19 2015
STATUS
approved