Factorions: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added the REXX computer programming language for this task.)
m (→‎{{header|REXX}}: optimized the two inner DO loops.)
Line 264: Line 264:


do base=LOb to HIb /*process all the required bases. */
do base=LOb to HIb /*process all the required bases. */
@= /*initialize the list (@) to null. */
@= 1 2 /*initialize the list (@) to null. */
do j=1 for lim; $= 0 /*initialize the sum ($) to zero. */
do j=3 for lim-2; $= 0 /*initialize the sum ($) to zero. */
t= j /*define the target (for the sum !'s).*/
t= j /*define the target (for the sum !'s).*/
do while t>0; d= t // base /*obtain a "digit".*/
do until t==0; d= t // base /*obtain a "digit".*/
$= $ + !.d /*add !(d) to sum.*/
$= $ + !.d /*add !(d) to sum.*/
t= t % base /*get a new target.*/
t= t % base /*get a new target.*/
end /*while*/
end /*until*/
if $==j then @= @ j /*Good factorial sum? Then add to list.*/
if $==j then @= @ j /*Good factorial sum? Then add to list.*/
end /*i*/
end /*i*/
say
say
say 'The factorions for base ' base " are:" @
say 'The factorions for base ' base " are: " @
end /*base*/
end /*base*/
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */