A386838 Minimum number of unit squares that a straight line drawn from (0,0) to (x,y) passes through on the square lattice where x^2 + y^2 = A001481(n). If A001481(n) can be written as a sum of two squares in two or more ways, x and y are chosen such that a(n) is the least value.
0, 0, 1, 0, 2, 2, 0, 3, 4, 0, 4, 3, 4, 0, 5, 6, 4, 7, 0, 6, 6, 8, 6, 0, 5, 8, 8, 9, 10, 0, 8, 8, 6, 10, 11, 8, 0, 9, 10, 12, 9, 12, 7, 0, 10, 10, 13, 12, 14, 12, 12, 0, 11, 10, 8, 13, 14, 14, 0, 12, 15, 12, 16, 12, 16, 12, 9, 16, 0, 13, 14, 15, 12, 18, 16, 18, 17, 0, 14
Offset: 1
Keywords
Examples
a(4) = 0 since A001481(4) = 4 and 4 = 2^2 + 0^2. A straight line from (0,0) to (2,0) stays on the x axis and therefore passes through no unit squares. a(5) = 2 since A001481(5) = 5 and 5 = 2^2 + 1^2. A straight line from (0,0) to (2,1) passes through two unit squares. It looks like this: _ _ (2,1) |_|_| (0,0) a(6) = 2 since A001481(6) = 8 and 8 = 2^2 + 2^2. A straight line from (0,0) to (2,2) passes through two unit squares. It looks like this: _ (2,2) _|_| |_| (0,0) a(16) = 6 since A001481(16) = 29 and 29 = 5^2 + 2^2. A straight line from (0,0) to (5,2) passes through six unit squares. It looks like this: _ _ _ (5,2) _ _|_|_|_| |_|_|_| (0,0) a(14) = 0 since A001481(14) = 25 and 25 = 5^2 + 0^2 = 4^2 + 3^2. x + y - gcd(x,y) is minimal for x = 5 and y = 0 and is equal to zero, therefore a(14) = 0.
Links
- Miles Englezou, Table of n, a(n) for n = 1..10000
Programs
-
PARI
a(n) = my(f, S, T = []); (f(n) = my(P = []); for(x=0, sqrtint(n), my(y2 = n - x^2); if(issquare(y2), my(y = sqrtint(y2)); if(x <= y, P = concat(P, [[x, y]])))); return(P)); S = f(n); if(#S == 0, return(0), for(k = 1, #S, T = concat(T, S[k][1] + S[k][2] - gcd(S[k][1], S[k][2]))); return(vecmin(T))) \\ function will also return 0 for n not in A001481 so any loop of a(n) must filter n
Comments