Factorions: Difference between revisions

Content added Content deleted
(Added Sidef)
m (→‎{{header|REXX}}: changed program indentations, added whitespace to program and output.)
Line 438: Line 438:
if lim=='' | lim=="," then lim= 1500000 - 1 /* " " " " " " */
if lim=='' | lim=="," then lim= 1500000 - 1 /* " " " " " " */


do fact=0 for HIb; !.fact= !(fact) /*use memoization for factorials. */
do fact=0 to HIb; !.fact= !(fact) /*use memoization for factorials. */
end /*fact*/
end /*fact*/


do base=LOb to HIb /*process all the required bases. */
do base=LOb to HIb /*process all the required bases. */
@= 1 2 /*initialize the list (@) to null. */
@= 1 2 /*initialize the list (@) to null. */
do j=3 for lim-2; $= 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 until 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 /*until*/
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 ' right( base, length(HIb) ) " 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. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 459: Line 459:
{{out|output|text=  when using the default inputs:}}
{{out|output|text=  when using the default inputs:}}
<pre>
<pre>
The factorions for base 9 are: 1 2 41282
The factorions for base 9 are: 1 2 41282


The factorions for base 10 are: 1 2 145 40585
The factorions for base 10 are: 1 2 145 40585