diff options
Diffstat (limited to 'std/Math.bruijn')
-rw-r--r-- | std/Math.bruijn | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/std/Math.bruijn b/std/Math.bruijn index 84cfae2..534afae 100644 --- a/std/Math.bruijn +++ b/std/Math.bruijn @@ -223,8 +223,7 @@ pascal L.iterate [L.zip-with …+… (L.{}(+0) ++ 0) (0 ; (+0))] (L.{}(+1)) # characteristic prime sequence by Tromp characteristic-primes ki : (ki : (sieve s0)) ⧗ (List Bool) - sieve y [[k : ([(2 0) (y' 0)] (ssucc 0))]] - y' [[0 0] [1 (0 0)]] + sieve y [[k : ([(2 0) (y 0)] (ssucc 0))]] ssucc [[[[1 : (0 (3 2))]]]] s0 [[[ki : (0 2)]]] @@ -237,6 +236,12 @@ primes* L.nub ((…≠?… (+1)) ∘∘ gcd) (L.iterate ++‣ (+2)) ⧗ (List Nu # primality test prime? L.index characteristic-primes ⧗ Number → Boolean +:test (prime? (+2)) ([[1]]) +:test (prime? (+3)) ([[1]]) +:test (prime? (+4)) ([[0]]) +:test (prime? (+5)) ([[1]]) +:test (prime? (+6)) ([[0]]) + # prime factors factors \divs primes ⧗ Number → (List Number) divs y [[&[[&[[3 ⋅ 3 >? 4 case-1 (=?0 case-2 case-3)]] (quot-rem 2 1)]]]] |