Yellowstone sequence: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added the REXX computer programming language for this task.) |
m (→{{header|REXX}}: simplified the logic.) |
||
Line 79: | Line 79: | ||
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 | gcd(k, @.prev)<2 then iterate /*not meet requirement?*/ |
|||
#= #+1; @.#= k; !.k= 1; $= $ k /*bump ctr; assign; mark used; add list*/ |
|||
leave /*find the next Yellowstone seq. number*/ |
|||
end /*k*/ |
|||
end |
end /*j*/ |
||
say $ /*display a list of a Yellowstone seq. */ |
|||
say $ |
|||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
gcd: parse arg x,y; |
gcd: parse arg x,y; do until y==0; parse value x//y y with y x; end; return x</lang> |
||
{{out|output|text= when using the default input:}} |
{{out|output|text= when using the default input:}} |
||
<pre> |
<pre> |