A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 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