RosettaCodeData/Task/Count-in-factors/PicoLisp/count-in-factors.l
2023-07-01 13:44:08 -04:00

11 lines
311 B
Text

(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)
(if (=0 (% N D))
(setq M (sqrt (setq N (/ N (link D)))))
(inc 'D (pop 'L)) ) )
(link N) ) ) )
(for N 20
(prinl N ": " (glue " * " (factor N))) )