]> gitweb.factorcode.org Git - factor.git/commitdiff
math: some docs tweaks for gcd and mod-inv
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 31 Jan 2024 00:47:38 +0000 (16:47 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 31 Jan 2024 00:47:38 +0000 (16:47 -0800)
basis/math/functions/functions-docs.factor
core/math/math-docs.factor

index fad3c6f4a5e09f54e4e203ba165e0d10ccd9f86c..e3bbc09dc480ae0c37d2a14748ba45e50fc90078 100644 (file)
@@ -294,7 +294,7 @@ HELP: divisor?
 
 HELP: mod-inv
 { $values { "x" integer } { "n" integer } { "y" integer } }
-{ $description "Outputs an integer " { $snippet "y" } " such that " { $snippet "xy = 1 (mod n)" } "." }
+{ $description "Outputs an integer " { $snippet "y" } " such that " { $snippet "x*y = 1 (mod n)" } "." }
 { $errors "Throws an error if " { $snippet "n" } " is not invertible modulo " { $snippet "n" } "." }
 { $examples
     { $example "USING: math.functions prettyprint ;" "173 1119 mod-inv ." "815" }
index 38319f895fe0b2c8424cb96eab3fe7249750aee0..5f741a94733ee7b4b20c27eb7c6a0b4a49d02e86 100644 (file)
@@ -246,7 +246,11 @@ HELP: >rect
 HELP: gcd
 { $values { "x" integer } { "y" integer } { "a" integer } { "d" integer } }
 { $description "Computes the positive greatest common divisor " { $snippet "d" } " of " { $snippet "x" } " and " { $snippet "y" } ", and another value " { $snippet "a" } " satisfying:" { $code "(a*x - d) mod y == 0" } }
-{ $notes "If " { $snippet "d" } " is 1, then " { $snippet "a" } " is the inverse of " { $snippet "y" } " modulo " { $snippet "x" } "." } ;
+{ $notes "If " { $snippet "d" } " is 1, then " { $snippet "a" } " is the inverse of " { $snippet "x" } " modulo " { $snippet "y" } "." }
+{ $examples
+    { $example "USING: kernel math prettyprint ;" "54 26 gcd [ . ] bi@" "1\n2" }
+    { $example "USING: math prettyprint ;" "54 1 * 2 - 26 mod ." "0" }
+} ;
 
 HELP: lcm
 { $values { "a" integer } { "b" integer } { "c" integer } }