cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A355884 Number of circles in an n X n grid passing through at least three points.

This page as a plain text file.
%I A355884 #33 Sep 24 2022 08:17:30
%S A355884 0,0,1,34,223,997,3402,9141,21665,46390,90874,167539,293443,487082,
%T A355884 781537,1209469,1816528,2661113,3822203,5369662,7420495,10086360,
%U A355884 13494376
%N A355884 Number of circles in an n X n grid passing through at least three points.
%H A355884 C. Lin, <a href="https://math.stackexchange.com/questions/273348/number-of-circles-in-configuration">Number of circles in configuration</a>, Mathematics Stack Exchange, 2013.
%o A355884 (PARI) \\ after user joriki's Java code at Mathematics Stack Exchange link
%o A355884 circles(n) = {
%o A355884   my(C = List());
%o A355884   for (x1 = 1, n,
%o A355884     for (y1 = 1, n,
%o A355884       for (x2 = 1, x1,
%o A355884         for (y2 = 1, n,
%o A355884           for (x3 = 1, x2,
%o A355884             for (y3 = 1, n,
%o A355884                 my( ax2 = 2 * (x2 - x1),
%o A355884                   ay2 = 2 * (y2 - y1),
%o A355884                   ax3 = 2 * (x3 - x1),
%o A355884                   ay3 = 2 * (y3 - y1),
%o A355884                   den = ax2 * ay3 - ax3 * ay2
%o A355884                 );
%o A355884               if (den == 0, next);
%o A355884                 my( b2 = x2^2 + y2^2 - x1^2 - y1^2,
%o A355884                   b3 = x3^2 + y3^2 - x1^2 - y1^2,
%o A355884                   x = b2 * ay3 - b3 * ay2,
%o A355884                   y = ax2 * b3 - ax3 * b2,
%o A355884                   gc = gcd(gcd(x, y), den)
%o A355884                 );
%o A355884               if (den < 0, gc = -gc);
%o A355884                 x /= gc; y /= gc; den /= gc;
%o A355884                 my( dx = x - den * x1,
%o A355884                   dy = y - den * y1,
%o A355884                   s = dx^2 + dy^2
%o A355884                 );
%o A355884               listput(C, [x, y, s, den])
%o A355884   ))))));
%o A355884   Set(C)
%o A355884 };
%o A355884 for (k = 0, 10, print1(#circles(k), ", "))  \\ _Hugo Pfoertner_, Sep 22 2022
%Y A355884 Cf. A192493, A192494, A357301.
%K A355884 nonn,hard,more
%O A355884 0,4
%A A355884 _Sharvil Kesarwani_, Jul 20 2022