Count in factors: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Added comments for function groupings.)
(Explicitly including the factor function)
Line 123: Line 123:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
Use the 'factor' function from [[Prime decomposition#PicoLisp]].
This is the 'factor' function from [[Prime decomposition#PicoLisp]].
<lang PicoLisp>(for N 20
<lang PicoLisp>(de factor (N)
(make
(let (D 2 L (1 2 2 . (4 2 4 2 4 6 2 6 .)) M (sqrt N))
(while (>= M D)
(ifn (=0 (% N D))
(inc 'D (pop 'L))
(link D)
(setq M (sqrt (setq N (/ N D)))) ) )
(or (= 1 N) (link N)) ) ) )

(for N 20
(prinl N ": " (or (glue " * " (factor N)) 1)) )</lang>
(prinl N ": " (or (glue " * " (factor N)) 1)) )</lang>
Output:
Output: