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.

A239318 Number of visible unit cubes, aligned with a three-dimensional Cartesian mesh, completely within the first octant of a sphere centered at the origin, ordered by increasing radius.

This page as a plain text file.
%I A239318 #7 Mar 25 2014 00:00:15
%S A239318 1,3,6,6,7,10,12,12,15,15,18,18,21,22,25,25,28,30,30,33,33,36,39,39,
%T A239318 39,42,42,43,43,46,49,49,52,52,54,57,57,60,63,66,66,66,66,69,69,72,72,
%U A239318 73,76,79,79,82,82,82,82,87,90,93,93,93,93,96,96,99,99,102
%N A239318 Number of visible unit cubes, aligned with a three-dimensional Cartesian mesh, completely within the first octant of a sphere centered at the origin, ordered by increasing radius.
%C A239318 This sequence is related to A237707, which gives all unit cubes. For each element in that sequence, this sequence gives the number of cubes that have at least one side that is visible from the sphere.
%o A239318 (C)
%o A239318 void printVisibleCubes(int nr)
%o A239318 {
%o A239318     int prev_c = 0;
%o A239318     for (int r = 3; nr > 0; r++)
%o A239318     {
%o A239318         int c = 0;
%o A239318         int c2 = 0;
%o A239318         for (int i = 1; i*i + 2 <= r; i++)
%o A239318             for (int j = 1; i*i + j*j + 1 <= r; j++)
%o A239318                 for (int k = 1; i*i + j*j + k*k <= r; k++)
%o A239318                 {
%o A239318                     c++;
%o A239318                     if (   (i+1)*(i+1) + j*j + k*k > r
%o A239318                         || i*i + (j+1)*(j+1) + k*k > r
%o A239318                         || i*i + j*j + (k+1)*(k+1) > r)
%o A239318                         c2++;
%o A239318                 }
%o A239318         if (c > prev_c)
%o A239318         {
%o A239318             // c contains next element of A237707
%o A239318             printf("%d, ", c2);
%o A239318             prev_c = c;
%o A239318             nr--;
%o A239318         }
%o A239318     }
%o A239318 }
%Y A239318 Cf. A237707.
%K A239318 nonn
%O A239318 1,2
%A A239318 _Frans Faase_, Mar 15 2014