Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Hofstadter-Q-sequence/Racket/hofstadter-q-sequence.rkt
Normal file
16
Task/Hofstadter-Q-sequence/Racket/hofstadter-q-sequence.rkt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#lang racket
|
||||
|
||||
(define t (make-hash))
|
||||
(hash-set! t 0 0)
|
||||
(hash-set! t 1 1)
|
||||
(hash-set! t 2 1)
|
||||
|
||||
(define (Q n)
|
||||
(hash-ref! t n (λ() (+ (Q (- n (Q (- n 1))))
|
||||
(Q (- n (Q (- n 2))))))))
|
||||
|
||||
(for/list ([i (in-range 1 11)]) (Q i))
|
||||
(Q 1000)
|
||||
|
||||
;; extra credit
|
||||
(for/sum ([i 100000]) (if (< (Q (add1 i)) (Q i)) 1 0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue