1 USING: help.markup help.syntax kernel math sequences ;
4 { next-prime prime? } related-words
7 { $values { "n" integer } { "p" "a prime number" } }
8 { $description "Return the next prime number greater than " { $snippet "n" } "." } ;
11 { $values { "n" integer } { "?" boolean } }
12 { $description "Test if an integer is a prime number." } ;
14 { nprimes primes-upto primes-between } related-words
17 { $values { "n" "a non-negative integer" } { "seq" sequence } }
18 { $description "Return a sequence containing the " { $snippet "n" } " first primes numbers." } ;
21 { $values { "n" integer } { "seq" sequence } }
22 { $description "Return a sequence containing all the prime numbers smaller or equal to " { $snippet "n" } "." } ;
25 { $values { "low" integer } { "high" integer } { "seq" sequence } }
26 { $description "Return a sequence containing all the prime numbers between " { $snippet "low" } " and " { $snippet "high" } "." } ;
28 HELP: find-relative-prime
33 { $description "Returns a number that is relatively prime to " { $snippet "n" } "." } ;
35 HELP: find-relative-prime*
37 { "n" integer } { "guess" integer }
40 { $description "Returns a number that is relatively prime to " { $snippet "n" } ", starting by trying " { $snippet "guess" } "." } ;
47 { $description "Returns a prime number exactly " { $snippet "numbits" } " bits in length, with the topmost bit set to one." } ;
55 { $description "Generates a sequence of " { $snippet "n" } " unique prime numbers with exactly " { $snippet "numbits" } " bits." } ;
57 ARTICLE: "math.primes" "Prime numbers"
58 "The " { $vocab-link "math.primes" } " vocabulary implements words related to prime numbers. Several useful vocabularies exist for testing primality. The Sieve of Eratosthenes in " { $vocab-link "math.primes.erato" } " is useful for testing primality below five million. For larger integers, " { $vocab-link "math.primes.miller-rabin" } " is a fast probabilistic primality test. The " { $vocab-link "math.primes.lucas-lehmer" } " vocabulary implements an algorithm for finding huge Mersenne prime numbers." $nl
59 "Testing if a number is prime:"
60 { $subsections prime? }
61 "Generating prime numbers:"
68 "Generating relative prime numbers:"
73 "Make a sequence of random prime numbers:"
74 { $subsections unique-primes } ;