(gcd a b)
Greatest common divisor between a and b
Greatest common divisor between a and b
(lcm a b)
(lcm a b & others)
Least common multiple of a and b
Least common multiple of a and b
(manhattan [x1 y1] [x2 y2])
Computes the Manhattan distance between two points
Computes the Manhattan distance between two points
(mod-div m a b)
Computes a / b mod m Note that b^-1 does not always exist for all b for all m (b and m must be co-prime)
Computes a / b mod m Note that b^-1 does not always exist for all b for all m (b and m must be co-prime)
(mod-geometric-sum m a n)
The sum of the geometric sequence 1 + a + a^2 + ... + a^n, with all operations modulo m Formula from https://stackoverflow.com/questions/42032824/geometric-series-modulus-operation
The sum of the geometric sequence 1 + a + a^2 + ... + a^n, with all operations modulo m Formula from https://stackoverflow.com/questions/42032824/geometric-series-modulus-operation
(mod-inverse m a)
Computes the multiplicative inverse of a, mod m
Computes the multiplicative inverse of a, mod m
(mod-linear-comp _ x)
(mod-linear-comp m [a2 b2] [a1 b1])
Takes two linear functions of the form f(x) = a1x + b1 and g(x) = a2x + b2 (both modulo m), and determines the coefficients of the composite function (g(f(x)))
Takes two linear functions of the form f(x) = a1*x + b1 and g(x) = a2*x + b2 (both modulo m), and determines the coefficients of the composite function (g(f(x)))
(mod-linear-inverse m [a b])
Coefficients of the inverse of a linear function of the form (f(x) = a*x + b modulo m
Coefficients of the inverse of a linear function of the form (f(x) = a*x + b modulo m
(mod-linear-pow m n [a b])
Determines the coefficients of the a linear function composed on itself multiple times, i.e., if f(x) = a*x + b, determines f^n(x) = f(f(f(f...(f(x))))) with n nestings
[a b]^n = [a^n (a^(n-1) + a^(n-2) + ... + a^1 + 1)b]
Should be equivalent to (first (drop n (iterate (partial mod-linear-comp m) [a b])))
Determines the coefficients of the a linear function composed on itself multiple times, i.e., if f(x) = a*x + b, determines f^n(x) = f(f(f(f...(f(x))))) with n nestings [a b]^n = [a^n (a^(n-1) + a^(n-2) + ... + a^1 + 1)b] Should be equivalent to (first (drop n (iterate (partial mod-linear-comp m) [a b])))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close