x: basic frequency (Hz) (number > 0) n: maximum harmonic factor (integer > 0) #### ( x <= y ) &&( y <= n * x ) #### =for Example: sub Harmonics ($$) { ...add your code here... } print join( "\n", Harmonics( 100, 6 ) ); # would print the following (without comments): 100.000 # 100 * 1/1 120.000 # 100 * 6/5 125.000 # 100 * 5/4 133.333 # 100 * 4/3 150.000 # 100 * 3/2 166.667 # 100 * 5/3 200.000 # 100 * 2/1 250.000 # 100 * 5/2 300.000 # 100 * 3/1 400.000 # 100 * 4/1 500.000 # 100 * 5/1 600.000 # 100 * 6/1 =cut #### #!usr/bin/perl -w sub Harmonics ($$) { for$i(1..$_[1]){for$j(1..$i){$y{sprintf"%.3f",$_[0]*$i/$j}=1}}sort{$a<=>$b}keys%y } print join( "\n", Harmonics( 100, 6 ) );