Factors of an integer: Difference between revisions

add Refal
m (Reordering BASIC dialects)
(add Refal)
(One intermediate revision by one other user not shown)
Line 6,029:
print mold/flat sort factors num
]</syntaxhighlight>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Prout <Factors 120>>;
}
 
Factors {
s.N = <Factors (s.N 1)>;
(s.N s.D), <Compare s.N <* s.D s.D>>: '-' = ;
(s.N s.D), <Divmod s.N s.D>: {
(s.D) 0 = s.D;
(s.F) 0 = s.D <Factors (s.N <+ 1 s.D>)> s.F;
(s.X) s.Y = <Factors (s.N <+ 1 s.D>)>;
};
};</syntaxhighlight>
{{out}}
<pre>1 2 3 4 5 6 8 10 12 15 20 24 30 40 60 120</pre>
 
=={{header|Relation}}==
Line 7,047 ⟶ 7,064:
{{libheader|Wren-fmt}}
{{libheader|Wren-math}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
import "./math" for Int
 
var a = [11, 21, 32, 45, 67, 96, 159, 723, 1024, 5673, 12345, 32767, 123459, 999997]
System.print("The factors of the following numbers are:")
for (e in a) SystemFmt.print("%(Fmt.d(6$6d => $n", e)), => %(Int.divisors(e))")</syntaxhighlight>
{{out}}
<pre>
2,115

edits