Pancake numbers: Difference between revisions

→‎{{header|REXX}}: reformatted and refurbished
m (→‎{{header|REXX}}: make it executabke as is)
(→‎{{header|REXX}}: reformatted and refurbished)
Line 1,164:
{{trans|Go}}
{{trans|Phix}}
<syntaxhighlight lang="rexx">/*REXX program calculates/displays ten 20 pancake numbers (from 1 ──►to 20, inclusive). */
/* Gerard pad= center('Schildberger's code reformatted and refurbished , 10) /*indentation. */
say pad center=copies('pancakes ', 10) ) center('pancake flips', 15 ) /*show the hdr /*indentation. */
say Say pad center('pancakes',10 , 10, "─") center('pancake flips',15) 15, "─") /*show the " " sephdr.*/
Say pad center('' ,10,"-") center('',15,"-") /* " " sep.*/
 
Do pcn=1 To 20
do #=1 for 20; say pad center(#, 10) center( pancake(#), 15) /*index, flips.*/
Say pad center(pcn,10) center(pancake(pcn),15) /*index,flips. */
end /*#*/
End
exit 0
Exit /*stick a fork in it, we're all done. */
/*------------------------------------------------------------------------------*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
pancake: Procedure
pancake: procedure; parse arg n; gap= 2 /*obtain N; initialize the GAP. */
Parse Arg n /* obtain N sum= 2 /* initialize the SUM. */
gap= 2 do adj=0 while sum <n /*perform whileinitialize the GAP. SUM is less than N. */
sum= 2 gap= gap*2 - 1 /*calculate initialize the GAPSUM. */
Do adj=0 While sum <n sum= sum + gap /*add theperform GAP to thewhile SUM. is less than N. */
gap= gap*2 - 1 end /*adj calculate the GAP. */
sum= sum + gap return n +adj -1 /* add the GAP /*returnto anthe adjusted adjustment sumSUM. */</syntaxhighlight>
endEnd /*#adj*/
Return n +adj -1 /* return an adjusted adjustment sum. */ </syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
2,295

edits