Count in factors: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added closing tags ---- }} ---- for the output section template.)
(→‎{{header|Factor}}: edit whitespace, show all vocabs, style tweaks)
Line 1,252: Line 1,252:


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>USING: io kernel math.primes.factors math.ranges prettyprint
<lang factor>
sequences ;
USING: math.parser math.primes.factors math.ranges ;

IN: scratchpad "1: 1" print 2 20 [a,b] [ dup pprint ": " write factors [ number>string ] map " x " join print ] each
: .factors ( n -- )
</lang>
dup pprint ": " write factors
[ " × " write ] [ pprint ] interleave nl ;

"1: 1" print 2 20 [a,b] [ .factors ] each</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,261: Line 1,265:
2: 2
2: 2
3: 3
3: 3
4: 2 x 2
4: 2 × 2
5: 5
5: 5
6: 2 x 3
6: 2 × 3
7: 7
7: 7
8: 2 x 2 x 2
8: 2 × 2 × 2
9: 3 x 3
9: 3 × 3
10: 2 x 5
10: 2 × 5
11: 11
11: 11
12: 2 x 2 x 3
12: 2 × 2 × 3
13: 13
13: 13
14: 2 x 7
14: 2 × 7
15: 3 x 5
15: 3 × 5
16: 2 x 2 x 2 x 2
16: 2 × 2 × 2 × 2
17: 17
17: 17
18: 2 x 3 x 3
18: 2 × 3 × 3
19: 19
19: 19
20: 2 x 2 x 5
20: 2 × 2 × 5
</pre>
</pre>