#!/usr/bin/python """Try to find a simple formula to generate the harmonics found in the 12-tone scale. Best so far is ((x % 9) + 1) * 4 % 11. """ desired = set([1, 2, 3, 4, 5, 6, 8, 9, 10, 12]) def n_desired(modulus, jump, k): for ii in range(modulus): if (ii * jump + k) % modulus not in desired: return ii best_n_desired = 0 for modulus in range(30): for jump in range(modulus): for k in range(modulus): hits = n_desired(modulus, jump, k) if hits>= best_n_desired: print "(ii * %d + %d) %% %d gives %s" % ( jump, k, modulus, [(ii * jump + k) % modulus for ii in range(hits)] ) best_n_desired = hits