Anonymous user
Numbers with equal rises and falls: Difference between revisions
Numbers with equal rises and falls (view source)
Revision as of 13:14, 1 February 2021
, 3 years ago→{{header|REXX}}: simplified the code, optimized for speed.
Alextretyak (talk | contribs) m (→{{header|11l}}) |
m (→{{header|REXX}}: simplified the code, optimized for speed.) |
||
Line 1,406:
n= abs(n) /*use the absolute value of N. */
call init /*initialize the rise/fall database. */
do j=1 until #==n
s= 0 /*initialize the sum of rises/falls. */
do k=1 for
end /*k*/
if s\==0 then iterate /*Equal # of rises & falls? Then add it*/
#= # + 1 /*bump the count of numbers found. */
if append then $= $ j /*append to the list of numbers found. */
end /*j*/
if append then call show /*display a list of N numbers──►term.*/
else say 'the ' commas(n)th(n) " number is: " commas(
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
|