Challenge
Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD).
A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible.
Input
An integer \$n\$, representing the radius of the square grid from the origin along both \$x\$ and \$y\$ axes.
Output
A square grid centered at the origin, where each cell is:
- ". " (dot followed by a space) for a visible point
- "\$\ \ \$" (two spaces) for a non-visible point
Examples
Length from the origin: n = 6
. . . .
. . . . . . . . . .
. . . . . .
. . . . . . . .
. . . . . .
. . . . . . . . . . . . .
. .
. . . . . . . . . . . . .
. . . . . .
. . . . . . . .
. . . . . .
. . . . . . . . . .
. . . .
Length from the origin: n = 5
. . . . . . . .
. . . . . .
. . . . . . . .
. . . . . .
. . . . . . . . . . .
. .
. . . . . . . . . . .
. . . . . .
. . . . . . . .
. . . . . .
. . . . . . . .
Length from the origin: n = 4
. . . .
. . . . . .
. . . .
. . . . . . . . .
. .
. . . . . . . . .
. . . .
. . . . . .
. . . .
Length from the origin: n = 3
. . . .
. . . .
. . . . . . .
. .
. . . . . . .
. . . .
. . . .
Length from the origin: n = 2
. .
. . . . .
. .
. . . . .
. .
Length from the origin: n = 1
. . .
. .
. . .
(0, 0)
a. k. a. the origin be marked, too? I mean it is “visible” from the origin. The line of sight has a length of zero, but this should not harm the mathematical conception of “visibility”, right? May we be allowed to mark or leave the origin unmarked at our discretion? \$\endgroup\$