The procedure "spsubdiv(r,n)" finds all superparticular subdivisions of the given interval "r" into "n" superparticular steps; the output is in the form of a sequence (several things separated by commas) of lists (sequences inside square brackets), each list containing the n superparticular steps for that subdivision. Both the sequence and each list are sorted large to small, due to the algorithm. The procedure is recursive; it removes a superparticular step (i+1)/i and calls itself to find all the subdivisions of what's left over (into n-1 steps). When it gets down to trying to subdivide an interval r into n=1 step, either it returns the list [r] if it is superparticular, or returns NULL (the empty sequence) if it is not. When it returns from recursion, the returned sequence is made into a list "l" and each element is combined with the interval that was removed and added to the sequence of results. Actually, it throws away any recursion results with intervals larger than the one it removed, since that subdivision must have been found previously when the larger interval had been removed. Also, the largest interval must be smaller than r but at least as big as the nth root of r. (The "option remember" means it stores all its results, so if it gets called again with the same arguments, it immediately returns the result instead of recalculating it. This makes such recursive algorithms much faster, at the price of eating lots of memory; remove that option if that's a problem.) (The Maple "op(n,x)" command returns the nth operand of x; "op(x)" returns a sequence of all operands of x.)
spsubdiv := proc(r:rational,n:integer) local i,j,l,s; option remember;
if n=1 then
if numer(r)=denom(r)+1
then [r]
else ( NULL )
end if;
else
s := NULL;
for i from floor(1/(r-1))+1 while (1+1/i)^n >= r do
l := [spsubdiv( r/(1+1/i), n-1 )];
for j to nops(l) do
if op(1,op(j,l)) <= (1+1/i) then
s := s, [(1+1/i),op(op(j,l))];
end if
end do;
end do;
s;
end if;
end proc:
Note: Maple is mathematical software published by Waterloo Maple Software.
Also, syntax has changed since this was written; I have updated the syntax to that of 2017.
Note: Since writing this article on superparticular pentatonics, I have generated comparable tables for superparticular hexatonic (6-tone) scales (380 scales, 19KB) and superparticular heptatonic (7-tone) scales (2908 scales, 166KB).
Links below are to download the tables, with descriptions, for pentatonics supertab5.txt, for hexatonics supertab6.txt, and for heptatonics supertab7.txt.