OFFSET
1,2
COMMENTS
It seems that n divides a(n)^2 if and only if n divides A306271(n)^2.
a(n) >= sqrt(n) with equality if and only if n is a square. - Robert Israel, Feb 05 2019
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(n^2) = n.
a(p) = (p + 1)/2 for primes p > 2.
For odd primes p and q, a(p*q) = (p+q)/2. - Robert Israel, Feb 08 2019
EXAMPLE
a(10) = 6 because 10 divides 6^2 - 4^2 = 10, and 6 is the smallest possible value for x such that x > y >= 0 and that 10 divides x^2 - y^2.
a(87) = 16 because 87 divides 16^2 - 13^2 = 87, and 16 is the smallest possible value for x such that x > y >= 0 and that 87 divides x^2 - y^2.
MAPLE
f:= proc(n) local S, x, t;
S:= {0}:
for x from 1 do
t:= x^2 mod n;
if member(t, S) then return x
else S:= S union {t}
fi
od
end proc:
map(f, [$1..100]); # Robert Israel, Feb 05 2019
PROG
(PARI) a(n) = for(x=1, n, for(y=0, x-1, if((x^2-y^2)%n==0, return(x))))
(Python)
from itertools import count
def A306284(n):
y, a = 0, set()
for x in count(0):
if y in a: return x
a.add(y)
y = (y+(x<<1)+1)%n # Chai Wah Wu, Apr 25 2024
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Jianing Song, Feb 03 2019
STATUS
approved