login
a(n) is the smallest positive integer x such that x > y >= 0 and n divides x^2 - y^2.
2

%I #29 Apr 26 2024 04:03:51

%S 1,2,2,2,3,4,4,3,3,6,6,4,7,8,4,4,9,6,10,6,5,12,12,5,5,14,6,8,15,8,16,

%T 6,7,18,6,6,19,20,8,7,21,10,22,12,7,24,24,7,7,10,10,14,27,12,8,9,11,

%U 30,30,8,31,32,8,8,9,14,34,18,13,12,36,9,37,38,10,20,9,16,40,9,9,42,42,10,11,44,16

%N a(n) is the smallest positive integer x such that x > y >= 0 and n divides x^2 - y^2.

%C Different from A306271: here x^2 mod n is not necessarily a square. For most n, a(n) != A306271(n).

%C It seems that n divides a(n)^2 if and only if n divides A306271(n)^2.

%C a(n) >= sqrt(n) with equality if and only if n is a square. - _Robert Israel_, Feb 05 2019

%H Robert Israel, <a href="/A306284/b306284.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n^2) = n.

%F a(p) = (p + 1)/2 for primes p > 2.

%F For odd primes p and q, a(p*q) = (p+q)/2. - _Robert Israel_, Feb 08 2019

%e 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.

%e 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.

%p f:= proc(n) local S, x,t;

%p S:= {0}:

%p for x from 1 do

%p t:= x^2 mod n;

%p if member(t,S) then return x

%p else S:= S union {t}

%p fi

%p od

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Feb 05 2019

%o (PARI) a(n) = for(x=1, n, for(y=0, x-1, if((x^2-y^2)%n==0, return(x))))

%o (Python)

%o from itertools import count

%o def A306284(n):

%o y, a = 0, set()

%o for x in count(0):

%o if y in a: return x

%o a.add(y)

%o y = (y+(x<<1)+1)%n # _Chai Wah Wu_, Apr 25 2024

%Y Cf. A048152, A306271.

%K nonn,look

%O 1,2

%A _Jianing Song_, Feb 03 2019