Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

musical /prog/ challange

Name: Anonymous 2010-09-22 14:03

Create an ordered list of fractions which product of the numerator and denominator equals a specific integer n.

ex: n=60
1/60, 2/30, 3/20, 4/15, 5/12, etc....

then do it with a list of integers.

If you are fancy you can also create a scale from the fractions you've got which best matches western tempered tuning (or any you prefer).

Name: Anonymous 2010-09-22 16:10

>>7
prime factorisation
recursion
sorting

Not necessary:
for 1..60 -> $n { say "n=$n"; for 1..$n { $n %% $^a ?? say "\t$a/" ~ $n/$a !! 0 } }

There's a much cleaner way... but Rakudo doesn't always accept valid Perl code and I'm sick of prodding it into submission. I can't wait for Christmas. Note my heinous use of ternary in void context. Don't do it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List