Counting the spokes I’ve been playing around with wheel factorization (Wikipedia link) and wanted to know how many spokes there are in a given wheel. For a 2-7 wheel the circumference of this would be 210 and then I can count the multiples of 2, 3, 5 and 7 (without recounting overlapping multiples) between 11 to 210 to get the answer of 162 spokes for this wheel. Knowing this also tells me the number of gaps: 210 - 162 = 48 gaps in the wheel.
However, this method of just counting up every multiple quickly becomes impractical. For a 2-31 wheel I’d have to count every multiple of 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 and 31 between 37 and 200560490130. How can I calculate the spokes for a given wheel easily?
 A: To do this, you can use the principle of inclusion and exclusion (PIE), though it doesn't work for large $n$. This states: $$\Biggl|\bigcup_{i=1}^n A_i\Biggr| = \sum_{k = 1}^{n} (-1)^{k+1} \left( \sum_{1 \leq i_{1} < \cdots < i_{k} \leq n} \left| A_{i_{1}} \cap \cdots \cap A_{i_{k}} \right| \right)$$
I will write it out for $n=2,3$ and compute the number of multiples.

For 2: $P(A \cup B) = P(A)+P(B) - P(A \cap B)$. 
Now we have that there are $6/2=3$ multiples of $2$, $6/3=2$ multiples of $3$ and $6/(2\cdot3)=1$ multiples of $2\cdot3$, so in total we have $3+2-1=4$ multiples of either 3 or 2. 

For 3: $P(A \cup B) = P(A)+P(B)+P(C) - P(A \cap B)- P(A \cap C) \\ - P(B \cap C)+P(A \cap B \cap C)$
$$30/2+30/3+30/5-30/6-30/10-30/15+30/30 = 22$$
A: There once was a comment on the question that said to look at Euler’s totient function and I asked them to expand it into an answer but apparently they never did. And now those comments are gone, so I’ll answer the question myself.
So Euler’s totient is
$$\varphi (n)=n\prod_{n|p} \left ( 1-\frac{1}{p} \right ),$$  
where $p$ are the distinct factors of $n$. In my case though, this can be simplified to just
$$\prod_{n|p} \left ( p-1 \right )$$  
This tells me the number of integers that are coprime to the circumference of the wheel, which is all the numbers within the gaps of the wheel. Subtracting this from the circumference tells me the number of spokes in a wheel. This will work well for large wheels but for excessively large wheels it’s better to add the logs of the primes used instead of multiplying.
For example, $ 2\times 3 \times 5 \times 7 = 210$ is the circumference of a 2-7 factorization wheel, $ 1 \times 2 \times 4 \times 6 = 48$ are the number of gaps within that wheel and thus there are $201-48=162$ spokes of the wheel.
