Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Partition-function-P/Racket/partition-function-p.rkt
Normal file
28
Task/Partition-function-P/Racket/partition-function-p.rkt
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#lang racket
|
||||
|
||||
(require math/number-theory)
|
||||
|
||||
(define σ
|
||||
(let ((memo (make-hash)))
|
||||
(λ (z)
|
||||
(hash-ref! memo z
|
||||
(λ () (apply + (divisors z)))))))
|
||||
|
||||
(define p
|
||||
(let ((memo (make-hash '((0 . 1)))))
|
||||
(λ (n)
|
||||
(hash-ref!
|
||||
memo n
|
||||
(λ ()
|
||||
(let ((r (if (zero? n) 1
|
||||
(/ (for/sum ((k (in-range (sub1 n) -1 -1)))
|
||||
(* (σ (- n k))
|
||||
(p k)))
|
||||
n))))
|
||||
(when (zero? (modulo n 1000)) (displayln (cons n r) (current-error-port)))
|
||||
r))))))
|
||||
|
||||
(map p (range 1 30))
|
||||
(p 666)
|
||||
(p 1000)
|
||||
(p 10000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue