Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Smith-numbers/PicoLisp/smith-numbers.l
Normal file
22
Task/Smith-numbers/PicoLisp/smith-numbers.l
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(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 sumdigits (N)
|
||||
(sum format (chop N)) )
|
||||
(de smith (X)
|
||||
(make
|
||||
(for N X
|
||||
(let R (factor N)
|
||||
(and
|
||||
(cdr R)
|
||||
(= (sum sumdigits R) (sumdigits N))
|
||||
(link N) ) ) ) ) )
|
||||
(let L (smith 10000)
|
||||
(println 'first-10 (head 10 L))
|
||||
(println 'last-10 (tail 10 L))
|
||||
(println 'all (length L)) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue