Permuted multiples: Difference between revisions

Content added Content deleted
(→‎{{header|AppleScript}}: Additional edit to preamble.)
m (→‎{{header|REXX}}: simplified some code.)
Line 438: Line 438:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program finds and displays the smallest positive integer n such that ··· */
<lang rexx>/*REXX program finds and displays the smallest positive integer n such that ··· */
/*───────────────────────── 2*n, 3*n, 4*5, 5*6, and 6*n contain the same decimal digits.*/
/*───────────────────────── 2*n, 3*n, 4*5, 5*6, and 6*n contain the same decimal digits.*/
do n=1 /*increment N from unity. */
do n=1 /*increment N from unity 'til answer.*/
b= 2*n /*calculate product of 2*n*/
b= 2*n /*calculate the product of: 2*n */
t= 3*n /* " " " 3*n*/
t= 3*n /* " " " " 3*n */
if verify(t,b)>0 then iterate /*product have req. digs ?*/
if verify(t, b)>0 then iterate /* T not have required digs? Skip*/
q= 4*n /*calculate product of 4*n*/
q= 4*n /*calculate the product of: 4*n */
if verify(q,b)>0 then iterate /*product have req. digs ?*/
if verify(q, b)>0 then iterate /* Q not have required digs? Skip*/
if verify(q,t)>0 then iterate /* " " " " "*/
if verify(q, t)>0 then iterate /* " " " " " " */
v= 5*n /*calculate product of 5*n*/
v= 5*n /*calculate the product of: 5*n */
if verify(v,b)<0 then iterate /*product have req. digs ?*/
if verify(v, b)<0 then iterate /* V not have required digs? Skip*/
if verify(v,t)>0 then iteratr /* " " " " "*/
if verify(v, t)>0 then iterate /* " " " " " " */
if verify(v,q)>0 then iteratr /* " " " " "*/
if verify(v, q)>0 then iterate /* " " " " " " */
s= 6*n /*calculate product of 6*n*/
s= 6*n /*calculate the product of: 6*n */
if verify(s,b)>0 then iterate /*product have req. digs ?*/
if verify(s, b)>0 then iterate /* S not have required digs? Skip*/
if verify(s,t)>0 then iterate /* " " " " "*/
if verify(s, t)>0 then iterate /* " " " " " " */
if verify(s,q)>0 then iterate /* " " " " "*/
if verify(s, q)>0 then iterate /* " " " " " " */
if verify(s,v)>0 then iterate /* " " " " "*/
if verify(s, v)>0 then iterate /* " " " " " " */
leave /*found the numbers, show.*/
say ' n =' commas(n) /*display the value of: n */
end /*n*/
say ' 2*n =' commas(b) /* " " " " 2*n */
_= left('', 9) /*used for indentation. */
say ' 3*n =' commas(t) /* " " " " 3*n */
say _ ' n =' commas(n) /*display value of n. */
say ' 4*n =' commas(q) /* " " " " 4*n */
say _ '2*n =' commas(b) /* " " " 2*n. */
say ' 5*n =' commas(v) /* " " " " 5*n */
say _ '3*n =' commas(t) /* " " " 3*n. */
say ' 6*n =' commas(s) /* " " " " 6*n */
say _ '4*n =' commas(q) /* " " " 4*n. */
leave /*found the N number, time to leave.*/
end /*n*/
say _ '5*n =' commas(v) /* " " " 5*n. */
say _ '6*n =' commas(s) /* " " " 6*n. */
exit 0 /*stick a fork in it, we're all done. */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/