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,19 @@
(define distinct-divisors
(compose make-set prime-factors))
;; euler totient : Φ : n / product(p_i) * product (p_i - 1)
;; # of divisors <= n
(define (Φ n)
(let ((pdiv (distinct-divisors n)))
(/ (* n (for/product ((p pdiv)) (1- p))) (for/product ((p pdiv)) p))))
;; farey-sequence length |Fn| = 1 + sigma (m=1..) Φ(m)
(define ( F-length n) (1+ (for/sum ((m (1+ n))) (Φ m))))
;; farey sequence
;; apply the definition : O(n^2)
(define (Farey N)
(set! N (1+ N))
(make-set (for*/list ((n N) (d (in-range n N))) (rational n d))))

View file

@ -0,0 +1,28 @@
(for ((n (in-range 1 12))) ( printf "F(%d) %s" n (Farey n)))
F(1) { 0 1 }
F(2) { 0 1/2 1 }
F(3) { 0 1/3 1/2 2/3 1 }
F(4) { 0 1/4 1/3 1/2 2/3 3/4 1 }
F(5) { 0 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1 }
F(6) { 0 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1 }
F(7) { 0 1/7 1/6 1/5 1/4 2/7 1/3 2/5 3/7 1/2 4/7 3/5 2/3 5/7 3/4 4/5 5/6 6/7 1 }
F(8) { 0 1/8 1/7 1/6 1/5 1/4 2/7 1/3 3/8 2/5 3/7 1/2 4/7 3/5 5/8 2/3 5/7 3/4 4/5 5/6 6/7 7/8 1 }
F(9) { 0 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 1 }
F(10) { 0 1/10 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 3/10 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 7/10 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 9/10 1 }
F(11) { 0 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 3/7 4/9 5/11 1/2 6/11 5/9 4/7 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 1 }
(for (( n (in-range 100 1100 100))) (printf "|F(%d)| = %d" n (F-length n)))
|F(100)| = 3045
|F(200)| = 12233
|F(300)| = 27399
|F(400)| = 48679
|F(500)| = 76117
|F(600)| = 109501
|F(700)| = 149019
|F(800)| = 194751
|F(900)| = 246327
|F(1000)| = 304193
(for (( n '(10_000 100_000))) (printf "|F(%d)| = %d" n (F-length n)))
|F(10000)| = 30397487
|F(100000)| = 3039650755