Regular Star Polygons
A regular star polygon {n/k} is formed by connecting every k -th point out of n equally spaced points on a circle of radius r. The star polygon is valid when 1 < k < n/2 and gcd(n, k) = 1. Compute...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
The regular star polygon $\{p/q\}$, for coprime integers $p,q$ with $p < 2q < 0$, is a polygon formed from $p$ edges of equal length and equal internal angles, such that tracing the complete polygon wraps $q$ times around the centre. For example, $\{8/3\}$ is illustrated below:

The edges of a regular star polygon intersect one another, dividing the interior into several regions. Define the alternating shading of a regular star polygon to be a selection of such regions to shade, such that every piece of every edge has a shaded region on one side and an unshaded region on the other, with the exterior of the polygon unshaded. For example, the above image shows the alternating shading (in green) of $\{8/3\}$.
Let $A(p, q)$ be the area of the alternating shading of $\{p/q\}$, assuming that its inradius is $1$. (The inradius of a regular polygon, star or otherwise, is the distance from its centre to the midpoint of any of its edges.) For example, in the diagram above, it can be shown that central shaded octagon has area $8(\sqrt{2}-1)$ and each point's shaded kite has area $2(\sqrt{2}-1)$, giving $A(8,3) = 24(\sqrt{2}-1) \approx 9.9411254970$.
You are also given that $A(130021, 50008)\approx 10.9210371479$, rounded to $10$ digits after the decimal point.
Find $\displaystyle{\sum}_{n=3}^{34} A(F_{n+1},F_{n-1})$, where $F_j$ is the Fibonacci sequence with $F_1=F_2=1$ (so $A(F_{5+1},F_{5-1}) = A(8,3)$). Give your answer rounded to $10$ digits after the decimal point.
Problem 841: Regular Star Polygons
Mathematical Foundation
Theorem 1 (Area of a Regular Star Polygon). The area of the regular star polygon inscribed in a circle of radius is
Proof. Label the equally spaced points on the circle as with . The star polygon connects to for each . Since , this produces a single closed polygon visiting all vertices.
Decompose the polygon into triangles where is the center. Each triangle has two sides of length (the radii and ) with included angle . By the formula for the area of a triangle with two sides and included angle:
Summing over all triangles yields
Lemma 1 (Count of Valid Star Polygons). For , the number of valid values of (i.e., integers with and ) is
Proof. The integers with and number by definition of Euler’s totient. These coprime residues pair off as since and (because is either non-integer or not coprime to for ). Each pair has exactly one member in . Thus there are values of with and . Excluding (the convex regular polygon, not a star polygon) gives .
Lemma 2 (Ramanujan Sum Connection). Define the Ramanujan sum . Then , the Mobius function. Consequently,
since .
Proof. The identity is classical (see Hardy & Wright, Ch. 16). Since is real, its imaginary part vanishes. The left-hand side is .
Editorial
Optimized version* (sieve-based). We first generate the primes required by the search, then enumerate the admissible combinations and retain only the values that satisfy the final test.
Pseudocode
total = 0.0
For n from 5 to N:
For k from 2 to floor((n-1)/2):
If gcd(n, k) == 1 then
total += (n / 2.0) * sin(2 * pi * k / n)
Return total
Optimized version (sieve-based):
total = 0.0
Precompute smallest prime factor via sieve for gcd speedup
spf = sieve_smallest_prime_factor(N)
For n from 5 to N:
For k from 2 to floor((n-1)/2):
if gcd(n, k) == 1: # O(log n) via Euclidean algorithm
total += (n / 2.0) * sin(2 * pi * k / n)
Return total
Complexity Analysis
- Time: , since . Each inner iteration performs one () and one evaluation ( with standard libraries), so total time is in the worst case, or treating as amortized.
- Space: auxiliary (or if a sieve is used for acceleration).
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
/*
* Problem 841: Regular Star Polygons
*
* Sum of areas of all valid star polygons {n/k} inscribed in unit circle.
* Area({n/k}) = (n/2) * sin(2*pi*k/n)
* Valid when gcd(n,k) = 1 and 1 < k < n/2.
*/
int main() {
int N = 10000;
double total = 0.0;
const double PI = acos(-1.0);
for (int n = 3; n <= N; n++) {
for (int k = 2; k < n / 2 + 1; k++) {
if (n % 2 == 0 && k == n / 2) continue;
if (__gcd(n, k) == 1) {
total += (n / 2.0) * sin(2.0 * PI * k / n);
}
}
}
// Verify small case: {5/2} pentagram
double pent = 2.5 * sin(2.0 * PI * 2 / 5);
assert(abs(pent - 1.46946) < 0.001);
printf("%.3f\n", total);
return 0;
}
"""
Problem 841: Regular Star Polygons
Compute the sum of areas of all regular star polygons {n/k} for 3 <= n <= N,
with 1 < k < n/2 and gcd(n,k) = 1, inscribed in a unit circle.
Area of {n/k} = (n/2) * sin(2*pi*k/n).
"""
from math import gcd, sin, pi
# --- Method 1: Direct enumeration ---
def sum_star_areas_direct(N: int) -> float:
"""Sum areas of all valid star polygons up to N points."""
total = 0.0
for n in range(3, N + 1):
for k in range(2, n // 2 + 1):
if n % 2 == 0 and k == n // 2:
continue # degenerate
if gcd(n, k) == 1:
total += (n / 2) * sin(2 * pi * k / n)
return total
# --- Method 2: Using Ramanujan sum identity ---
def sum_star_areas_ramanujan(N: int) -> float:
"""Use the fact that sum over coprime k of sin(2pi*k/n) relates to mu(n)."""
total = 0.0
for n in range(3, N + 1):
# Sum sin(2*pi*k/n) for 1 < k < n/2, gcd(k,n) = 1
inner = 0.0
for k in range(2, n // 2 + 1):
if n % 2 == 0 and k == n // 2:
continue
if gcd(n, k) == 1:
inner += sin(2 * pi * k / n)
total += (n / 2) * inner
return total
# --- Method 3: Count by phi(n) ---
def count_star_polygons(N: int):
"""Count total number of valid star polygons."""
count = 0
for n in range(3, N + 1):
for k in range(2, n // 2 + 1):
if n % 2 == 0 and k == n // 2:
continue
if gcd(n, k) == 1:
count += 1
return count
# --- Verify methods agree ---
for N in range(3, 30):
a = sum_star_areas_direct(N)
b = sum_star_areas_ramanujan(N)
assert abs(a - b) < 1e-10, f"Mismatch at N={N}: {a} vs {b}"
print("Verification passed!")
# Compute answer
N = 10000
answer = sum_star_areas_direct(N)
print(f"S({N}) = {answer:.3f}")