Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Proper-divisors/PicoLisp/proper-divisors-1.l
Normal file
10
Task/Proper-divisors/PicoLisp/proper-divisors-1.l
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Generate all proper divisors.
|
||||
(de propdiv (N)
|
||||
(head -1 (filter
|
||||
'((X) (=0 (% N X)))
|
||||
(range 1 N) )) )
|
||||
|
||||
# Obtaining the values from 1 to 10 inclusive.
|
||||
(mapcar propdiv (range 1 10))
|
||||
# Output:
|
||||
# (NIL (1) (1) (1 2) (1) (1 2 3) (1) (1 2 4) (1 3) (1 2 5))
|
||||
21
Task/Proper-divisors/PicoLisp/proper-divisors-2.l
Normal file
21
Task/Proper-divisors/PicoLisp/proper-divisors-2.l
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
(de propdiv (N)
|
||||
(cdr
|
||||
(rot
|
||||
(make
|
||||
(for I N
|
||||
(and (=0 (% N I)) (link I)) ) ) ) ) )
|
||||
(de countdiv (N)
|
||||
(let C -1
|
||||
(for I N
|
||||
(and (=0 (% N I)) (inc 'C)) )
|
||||
C ) )
|
||||
(let F (-5 -8)
|
||||
(tab F "N" "LIST")
|
||||
(for I 10
|
||||
(tab F
|
||||
I
|
||||
(glue " + " (propdiv I)) ) ) )
|
||||
(println
|
||||
(maxi
|
||||
countdiv
|
||||
(range 1 20000) ) )
|
||||
24
Task/Proper-divisors/PicoLisp/proper-divisors-3.l
Normal file
24
Task/Proper-divisors/PicoLisp/proper-divisors-3.l
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(de accu1 (Var Key)
|
||||
(if (assoc Key (val Var))
|
||||
(con @ (inc (cdr @)))
|
||||
(push Var (cons Key 2)) )
|
||||
Key )
|
||||
(de factor (N)
|
||||
(let
|
||||
(R NIL
|
||||
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 (accu1 'R D)))) )
|
||||
(inc 'D (pop 'L)) ) )
|
||||
(accu1 'R N)
|
||||
(dec (apply * (mapcar cdr R))) ) )
|
||||
(bench
|
||||
(println
|
||||
(maxi
|
||||
factor
|
||||
(range 1 20000) )
|
||||
@@ ) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue