Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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