Euclid invented an algorithm to find the greatest commond divisor of two numbers.
It might be the first algorithm ever described.
It's based on the observation that the difference of the two numbers and the smaller of the two have the same CGD as the original pair of numbers. The steps of the algorithm involve continuous subtraction of the smaller number from the bigger number, until the remainder is zero or smaller than the smaller number.
See more details on Wikipedia;
Some clever dude named Godfried Toussaint discovered that this CGD algorithm can be used to describe most of the world's musical rhythms. Euclidean rhythms allow for equidistantly distributed accents in any number of beats.
See Wikipedia.
This can be programmed using the modulo operator in a loop. A software implementation with Arduino on GitHub.
Here's a short video demonstrating the rhythm.