OFFSET
0,4
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..55
C. Lin, Number of circles in configuration, Mathematics Stack Exchange, 2013.
PROG
(PARI) \\ after user joriki's Java code at Mathematics Stack Exchange link
circles(n) = {
my(C = List());
for (x1 = 1, n,
for (y1 = 1, n,
for (x2 = 1, x1,
for (y2 = 1, n,
for (x3 = 1, x2,
for (y3 = 1, n,
my( ax2 = 2 * (x2 - x1),
ay2 = 2 * (y2 - y1),
ax3 = 2 * (x3 - x1),
ay3 = 2 * (y3 - y1),
den = ax2 * ay3 - ax3 * ay2
);
if (den == 0, next);
my( b2 = x2^2 + y2^2 - x1^2 - y1^2,
b3 = x3^2 + y3^2 - x1^2 - y1^2,
x = b2 * ay3 - b3 * ay2,
y = ax2 * b3 - ax3 * b2,
gc = gcd(gcd(x, y), den)
);
if (den < 0, gc = -gc);
x /= gc; y /= gc; den /= gc;
my( dx = x - den * x1,
dy = y - den * y1,
s = dx^2 + dy^2
);
listput(C, [x, y, s, den])
))))));
Set(C)
};
for (k = 0, 10, print1(#circles(k), ", ")) \\ Hugo Pfoertner, Sep 22 2022
(Python)
# after Hugo Pfoertner's PARI code
from math import gcd
from itertools import product
from sympy.utilities.iterables import combinations_with_replacement
def A355884(n):
c, t = set(), 0
for x1, x2, x3 in combinations_with_replacement(range(1, n+1), 3):
for y1, y2, y3 in product(range(1, n+1), repeat=3):
den = (x1-x2)*(y1-y3)-(x1-x3)*(y1-y2)<<2
if den:
a, b = x1**2-x3**2+y1**2-y3**2<<1, x1**2-x2**2+y1**2-y2**2<<1
x = -(y1-y2)*a+(y1-y3)*b
y = (x1-x2)*a-(x1-x3)*b
gc = gcd(x, y, den)
if den < 0: gc = -gc
x //= gc
y //= gc
den //= gc
if (z:=(x, y, (x-den*x1)**2+(y-den*y1)**2, den)) not in c:
t += 1
c.add(z)
return t # Chai Wah Wu, Nov 30 2025
CROSSREFS
KEYWORD
nonn,hard
AUTHOR
Sharvil Kesarwani, Jul 20 2022
EXTENSIONS
a(23)-a(32) from Chai Wah Wu, Nov 30 2025
STATUS
approved
