Yellowstone sequence: Difference between revisions
Content added Content deleted
m (→horizontal list of numbers: optimized the inner DO loop.) |
m (→vertical histogram plot: optimized the multiple IF classes.) |
||
Line 937: | Line 937: | ||
!.= 0 /*initialize an array of numbers(used).*/ |
!.= 0 /*initialize an array of numbers(used).*/ |
||
# = 0 /*count of Yellowstone numbers in seq. */ |
# = 0 /*count of Yellowstone numbers in seq. */ |
||
$ |
$ = /*list " " " " " */ |
||
do j=1 until #==m; prev= # - 1 |
do j=1 until #==m; prev= # - 1 |
||
if j<5 then do; #= #+1; @.#= j; !.#= j; !.j= 1; $= strip($ j); iterate; end |
if j<5 then do; #= #+1; @.#= j; !.#= j; !.j= 1; $= strip($ j); iterate; end |
||
do k=1; if !.k then iterate /*Already used? Then skip this number.*/ |
do k=1; if !.k then iterate /*Already used? Then skip this number.*/ |
||
if gcd(k, @.#)\==1 |
if gcd(k, @.#) \==1 then iterate /*Not meet requirement? Then skip it. */ |
||
if gcd(k, @.prev)<2 then iterate /* " " " " " " */ |
|||
#= # + 1; @.#= k; !.k= 1; $= $ k /*bump ctr; assign; mark used; add list*/ |
|||
leave /*find the next Yellowstone seq. number*/ |
leave /*find the next Yellowstone seq. number*/ |
||
end /*k*/ |
end /*k*/ |
||
end /*j*/ |
end /*j*/ |
||
call $histo $ '(vertical)' |
call $histo $ '(vertical)' /*invoke a REXX vertical histogram plot*/ |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |