OFFSET
1,2
COMMENTS
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.
PROG
(C)
void printVisibleCubes(int nr)
{
int prev_c = 0;
for (int r = 3; nr > 0; r++)
{
int c = 0;
int c2 = 0;
for (int i = 1; i*i + 2 <= r; i++)
for (int j = 1; i*i + j*j + 1 <= r; j++)
for (int k = 1; i*i + j*j + k*k <= r; k++)
{
c++;
if ( (i+1)*(i+1) + j*j + k*k > r
|| i*i + (j+1)*(j+1) + k*k > r
|| i*i + j*j + (k+1)*(k+1) > r)
c2++;
}
if (c > prev_c)
{
// c contains next element of A237707
printf("%d, ", c2);
prev_c = c;
nr--;
}
}
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Frans Faase, Mar 15 2014
STATUS
approved