A371124 a(n) is the least nonnegative integer y such that y^2 = x^2 - k*n for k and x where n > k >= 1 and n > x >= floor(sqrt(n)).
0, 0, 1, 0, 2, 2, 3, 1, 0, 4, 5, 2, 6, 6, 1, 0, 8, 0, 9, 4, 2, 10, 11, 1, 0, 12, 3, 6, 14, 2, 15, 2, 4, 16, 1, 0, 18, 18, 5, 3, 20, 4, 21, 10, 2, 22, 23, 1, 0, 0, 7, 12, 26, 6, 3, 5, 8, 28, 29, 2, 30, 30, 1, 0, 4, 8, 33, 16, 10, 2, 35, 3, 36, 36, 5, 18, 2, 10
Offset: 1
Keywords
Examples
n | k | x | y^2 = x^2 - k*n | y ------------------------------------ 1 | 1 | 1 | 0^2 = 1^2 - 1*1 | 0 2 | 2 | 2 | 0^2 = 2^2 - 2*1 | 0 11 | 1 | 6 | 5^2 = 6^2 - 1*11 | 5
Programs
-
Python
from sympy.core.power import isqrt from sympy.ntheory.primetest import is_square def a(n): x = isqrt(n) while True: for y2 in range(x**2-n, -1, -n): if is_square(y2): return isqrt(y2) x+=1 print([a(n) for n in range(1, 79)])
-
Python
from itertools import count def A371124(n): y, a = 0, {} for x in count(0): if y in a: return a[y] a[y] = x y = (y+(x<<1)+1)%n # Chai Wah Wu, Apr 25 2024
Comments