Count in factors: Difference between revisions

→‎{{header|Factor}}: edit whitespace, show all vocabs, style tweaks
m (→‎{{header|REXX}}: added closing tags ---- }} ---- for the output section template.)
(→‎{{header|Factor}}: edit whitespace, show all vocabs, style tweaks)
Line 1,252:
 
=={{header|Factor}}==
<lang factor>USING: math.parserio 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}}
<pre>
Line 1,261 ⟶ 1,265:
2: 2
3: 3
4: 2 x× 2
5: 5
6: 2 x× 3
7: 7
8: 2 x× 2 x× 2
9: 3 x× 3
10: 2 x× 5
11: 11
12: 2 x× 2 x× 3
13: 13
14: 2 x× 7
15: 3 x× 5
16: 2 x× 2 x× 2 x× 2
17: 17
18: 2 x× 3 x× 3
19: 19
20: 2 x× 2 x× 5
</pre>
 
1,827

edits