Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
(define (fib n)
(let loop ((cnt 0) (a 0) (b 1))
(if (= n cnt)
a
(loop (+ cnt 1) b (+ a b)))))

View file

@ -0,0 +1,4 @@
(define (fib n (a 0) (b 1))
(if (< n 2)
1
(+ a (fib (- n 1) b (+ a b)))))

View file

@ -0,0 +1,11 @@
#lang racket
(require math/matrix)
(define (fibmat n) (matrix-ref
(matrix-expt (matrix ([1 1]
[1 0]))
n)
1 0))
(fibmat 1000)

View file

@ -0,0 +1,4 @@
(define (fib n)
(car (foldl (lambda (y x)
(let ((a (car x)) (b (cdr x)))
(cons b (+ a b)))) (cons 0 1) (range n))))