Created
March 6, 2019 08:37
-
-
Save paniq/0f96fdc56ee22a742b373364fc13d4c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Polyrhythmic Prime Discovery | |
# by Leonard Ritter <[email protected]> | |
primes = [] | |
phases = [] | |
counter = 2 | |
def is_any_phase_zero (): | |
for phase in phases: | |
if phase == 0: | |
return True | |
return False | |
def advance_phases (): | |
i = 0 | |
primecount = len(primes) | |
while (i < primecount): | |
# increase each phase in the modspace of its prime | |
# we're explicitly not using % here to show | |
# how simple this mechanism is. | |
x = phases[i] | |
x += 1 | |
if x == primes[i]: | |
x = 0 | |
phases[i] = x | |
i = i + 1 | |
while True: | |
if not is_any_phase_zero(): | |
# no phase is zero, we are off-beat | |
# therefore, we found a new prime | |
# print it | |
print counter | |
# and append to list of rhythms to track | |
primes.append(counter) | |
phases.append(0) | |
advance_phases() | |
counter += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment