Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Almost-prime/PicoLisp/almost-prime.l
Normal file
27
Task/Almost-prime/PicoLisp/almost-prime.l
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(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) ) ) )
|
||||
|
||||
(de almost (N)
|
||||
(let (X 2 Y 0)
|
||||
(make
|
||||
(loop
|
||||
(when (and (nth (factor X) N) (not (cdr @)))
|
||||
(link X)
|
||||
(inc 'Y) )
|
||||
(T (= 10 Y) 'done)
|
||||
(inc 'X) ) ) ) )
|
||||
|
||||
(for I 5
|
||||
(println I '-> (almost I) ) )
|
||||
|
||||
(bye)
|
||||
Loading…
Add table
Add a link
Reference in a new issue