Skip to content

Instantly share code, notes, and snippets.

@ggorlen
Last active December 28, 2025 23:26
Show Gist options
  • Select an option

  • Save ggorlen/84c6c3782df94048cef40bcb85d81421 to your computer and use it in GitHub Desktop.

Select an option

Save ggorlen/84c6c3782df94048cef40bcb85d81421 to your computer and use it in GitHub Desktop.
Draw minimal coprime stars
# see https://stackoverflow.com/questions/72943585/how-to-draw-n-pointed-stars-using-turtle#comment140920249_72943585
import math
from turtle import Screen, Turtle
def first_coprime(n):
for k in range(2, n):
if math.gcd(n, k) == 1:
return k
return None
n = 10
step = first_coprime(n)
radius = 200
points = []
for i in range(n):
angle = 2 * math.pi * i / n # Angle in radians
x = radius * math.cos(angle)
y = radius * math.sin(angle)
points.append((x, y))
t = Turtle()
t.speed(0)
t.penup()
t.goto(points[0])
t.pendown()
i = 0
for _ in range(n):
t.goto(points[i])
i = (i + step) % n
t.goto(points[0])
t.hideturtle()
Screen().exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment