Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
;; stern (2n ) = stern (n)
|
||||
;; stern(2n+1) = stern(n) + stern(n+1)
|
||||
|
||||
(define (stern n)
|
||||
(cond
|
||||
(( < n 3) 1)
|
||||
((even? n) (stern (/ n 2)))
|
||||
(else (let ((m (/ (1- n) 2))) (+ (stern m) (stern (1+ m)))))))
|
||||
(remember 'stern)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
; generate the sequence and check GCD
|
||||
(for ((n 10000))
|
||||
(unless (= (gcd (stern n) (stern (1+ n))) 1) (error "BAD GCD" n)))
|
||||
→ #t
|
||||
|
||||
;; first items
|
||||
(define sterns (cache 'stern))
|
||||
(subvector sterns 1 16)
|
||||
→ #( 1 1 2 1 3 2 3 1 4 3 5 2 5 3 4)
|
||||
|
||||
;; first occurences index
|
||||
(for ((i (in-range 1 11))) (write (vector-index i sterns)))
|
||||
→ 0 3 5 9 11 33 19 21 35 39
|
||||
|
||||
;; 100
|
||||
(writeln (vector-index 100 sterns))
|
||||
→ 1179
|
||||
|
||||
(stern 900000) → 446
|
||||
(stern 900001) → 2479
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
;; grouping
|
||||
(for ((i (in-range 2 40 2))) (write (/ (stern i)(stern (1+ i)))))
|
||||
→ 1/2 1/3 2/3 1/4 3/5 2/5 3/4 1/5 4/7 3/8 5/7 2/7 5/8 3/7 4/5 1/6 5/9 4/11 7/10
|
||||
|
||||
;; computing f(1), f(f(1)), etc.
|
||||
(define (f x)
|
||||
(let [(a (/ (- (floor x) -1 (fract x))))]
|
||||
(if (> a 1) (f a) (cons a a))))
|
||||
|
||||
(define T (make-stream f 1))
|
||||
(for((i 19)) (write (stream-iterate T)))
|
||||
|
||||
→ 1/2 1/3 2/3 1/4 3/5 2/5 3/4 1/5 4/7 3/8 5/7 2/7 5/8 3/7 4/5 1/6 5/9 4/11 7/10
|
||||
Loading…
Add table
Add a link
Reference in a new issue