Find the inverse of 3 modulo 11.
Show the steps
- Modular multiplicative inversea x \equiv 1 \pmod mwith
a = 3, m = 11→inverse = 4
Number theory, modular arithmetic, combinatorics, graph theory and network algorithms, logic and the mathematics of cryptography.
Discrete Math (discrete-math-ai999x) is an offline Python package for discrete math. It covers number theory, modular arithmetic, combinatorics, graph theory and network algorithms, logic and the mathematics of cryptography.
It has 99 capabilities — 99 computational procedures — in 7 topics, the largest being Combinatorics, Graph theory, Number theory, Cryptography, Logic and Modular arithmetic. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.
When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.
pip install discrete-math-ai999x hf download AI999X/discrete-math-ai999x --local-dir discrete-math-ai999x
Each question below was put to discrete-math-ai999x and the answer shown is the one it returned, with the steps it took.
Find the inverse of 3 modulo 11.
a = 3, m = 11inverse = 4Solve x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7).
residues = [2, 3, 2], moduli = [3, 5, 7]x = 23, modulus = 105How many derangements of 5 objects are there?
n = 5derangements = 44, probability = 0.3666666667m.solve("chromatic_number", edges="A-B, B-C, C-A, C-D") edges = A-B, B-C, C-A, C-Dchromatic_number = 3, colouring = {'A': 1, 'B': 2, 'C': 3, 'D': 1}Is (p -> q) | (q -> p) a tautology?
formula = (p -> q) | (q -> p)tautology = True, false_rows = 0, counterexample = NoneEncrypt "AFFINE CIPHER" with the affine cipher a = 5, b = 8.
a = 5, b = 8, message = AFFINE CIPHER, mode = encryptresult = IHHWVCSWFRCPConvert 1011 from base 2 to base 10.
digits = 1011, from_base = 2, to_base = 10result = 11, decimal = 11Compute the Carmichael function of 15.
n = 15lambda = 4Every snippet was run as shown; the output under it is what it printed.
import discrete_math_ai999x as m
a = m.ask("Find the inverse of 3 modulo 11.")
print(a.outcome)
print(a.values)
for step in a.steps:
print(step["name"])SOLVED
{'inverse': 4}
Modular multiplicative inverse
import discrete_math_ai999x as m
a = m.solve("chromatic_number", edges="A-B, B-C, C-A, C-D")
print(a.outcome)
print(a.values)SOLVED
{'chromatic_number': 3, 'colouring': {'A': 1, 'B': 2, 'C': 3, 'D': 1}}
import discrete_math_ai999x as m
# an input is missing: the answer says what it needs instead of guessing
a = m.solve("chromatic_number")
print(a.outcome)
print(a.message)NEEDS_INPUT
chromatic_number needs edges (the graph as a list of edges u-v (an optional third entry is the weight)). Example: solve('chromatic_number', edges='A-B, B-C, C-A, C-D').
discrete-math-ai999x "Find the inverse of 3 modulo 11."
inverse = 4 1. Modular multiplicative inverse: extended Euclidean algorithm with a = 3, m = 11 -> inverse = 4 Assumptions: m >= 2; gcd(a, m) = 1 (otherwise no inverse exists) …
Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.
12 of its 99 formulas; every one is in the capability browser below.
Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.
bellB_n: the number of partitions of an n-element set into any number of non-empty blocks.
n size of the set (0..200) integerbell the Bell number B_nbernoulliThe Bernoulli number B_n as an exact fraction (convention B_1 = -1/2).
n the index n (0..200) integervalue B_n as a decimalnumerator numerator of B_n in lowest termsdenominator denominator of B_n (positive)braceletsDistinct bracelets of n beads in k colours when rotations and flips count as the same.
beads number of beads n (1..60) integercolours number of colours k (1..60) integerbracelets classes under rotation and reflectionnecklaces classes under rotation onlycatalanC_n: balanced parenthesizations with n pairs, triangulations of an (n+2)-gon, full binary trees with n+1 leaves.
n the index n (0..500) integercatalan the Catalan number C_nbinomial_termThe coefficient of x^k in (a x + b)^n by the binomial theorem (exact integer).
a coefficient of x inside the bracket integerb constant inside the bracket integern the power n (0..1000) integerk the power of x asked for integercoefficient C(n, k) a^k b^(n-k)combinationsThe number of ways to choose k of n distinct items when order does not matter (exact integer).
n number of items to choose from (0..1000) integerk number chosen (0..n) integercombinations C(n, k) = n! / (k! (n-k)!)multisetsThe number of ways to choose k items from n types when types may repeat and order does not matter.
n number of types (at least 1) integerk number of items chosen integermultisets C(n + k - 1, k)inclusion_exclusionHow many integers in 1..n are divisible by at least one of the given numbers (and how many by none).
n the upper end of the range 1..n integerdivisors the divisors (whole numbers >= 1) vectordivisible_by_any count divisible by at least one divisordivisible_by_none count divisible by nonederangements!n: permutations of n items with no item in its original place, and the probability !n/n!.
n number of items (0..170) integerderangements !nprobability !n / n! (tends to 1/e)word_arrangementsThe number of distinct orderings of a word's letters, repeated letters counted once (multiset permutations).
word the word (letters A-Z; case is ignored) textarrangements n! / (n1! n2! ...) over the letter multiplicitieslength number of lettersletter_counts how often each letter occursfibonacciF_n with F_0 = 0, F_1 = 1, F_n = F_(n-1) + F_(n-2) (exact integer).
n the index n (0..1000) integerfibonacci F_ninteger_partitionsp(n): the number of ways to write n as a sum of positive integers, order ignored.
n the integer n (0..2000) integerpartitions p(n)stars_and_barsHow many integer solutions x1 + ... + xk = n have every xi between a lower and an optional upper bound (identical objects into distinct boxes).
total the total n (0..2000) integervariables the number of variables or boxes k (1..50) integerlower lower bound for every variable (0 = non-negative, 1 = positive) integer optionalupper optional upper bound for every variable integer optionalsolutions number of solutionslattice_pathsMonotone lattice paths using unit steps right and up from (0, 0) to (m, n): C(m + n, m).
right number of steps right m integerup number of steps up n integerpaths C(m + n, m)lucasL_n with L_0 = 2, L_1 = 1, L_n = L_(n-1) + L_(n-2) (exact integer).
n the index n (0..1000) integerlucas L_nmultinomialn! / (k1! k2! ... km!): ways to split n distinct items into labelled groups of the given sizes.
counts the group sizes k1, ..., km (whole numbers) vectortotal the stated total n (optional; must equal the sum of the sizes) integer optionalcoefficient the multinomial coefficienttotal n = k1 + ... + kmnecklacesDistinct necklaces of n beads in k colours when rotations count as the same (and bracelets, also flips).
beads number of beads n (1..60) integercolours number of colours k (1..60) integernecklaces classes under rotationbracelets classes under rotation and reflectionpartitions_distinctq(n): the number of ways to write n as a sum of distinct positive integers (equal to partitions into odd parts).
n the integer n (0..1000) integerpartitions q(n)partitions_kp(n, k): the number of ways to write n as a sum of exactly k positive integers, order ignored.
n the integer n (0..300) integerk the number of parts (0..300) integerpartitions p(n, k)permutationsThe number of ordered arrangements of k of n distinct items (exact integer); P(n, n) = n!.
n number of distinct items (0..170) integerk number arranged (0..n) integerpermutations P(n, k) = n! / (n-k)!pigeonhole_maxPlacing n objects into k boxes, some box must hold at least ceil(n / k) objects (and this is the best guarantee).
items number of objects n integerboxes number of boxes k integerguaranteed ceil(n / k): the largest load every placement must reach in some boxpigeonhole_neededHow many objects drawn from k categories guarantee at least r of one category: k (r - 1) + 1.
boxes number of categories k integerat_least the guaranteed count r in one category integerneeded k (r - 1) + 1sequences_with_repetitionThe number of length-k sequences over n symbols when symbols may repeat.
n number of available symbols (at least 1) integerk length of the sequence integersequences n^kstirling1c(n, k): permutations of n elements with exactly k cycles (unsigned), and the signed s(n, k).
n number of elements (0..100) integerk number of cycles (0..100) integerstirling1 unsigned c(n, k)signed signed s(n, k) = (-1)^(n-k) c(n, k)stirling2S(n, k): ways to partition an n-element set into k non-empty unlabelled blocks; k! S(n, k) onto functions.
n size of the set (0..100) integerk number of blocks (0..100) integerstirling2 S(n, k)surjections k! S(n, k): onto functions from an n-set to a k-setaffine_cipherEncrypt or decrypt with the affine cipher E(x) = a x + b (mod 26).
message the message (letters are kept, everything else is dropped) texta multiplier (coprime to 26) integerb shift integermode encrypt or decrypt choiceresult the result in capital letters, without spaces or punctuationcaesar_cipherEncrypt or decrypt a message with a Caesar shift of k letters.
message the message (letters are kept, everything else is dropped) textshift the shift k integermode encrypt or decrypt choiceresult the result in capital letters, without spaces or punctuationdiffie_hellmanThe public values A = g^a, B = g^b (mod p) and the shared secret g^(ab) mod p.
p the prime modulus integerg the generator (1 < g < p) integera Alice's secret exponent integerb Bob's secret exponent integerA Alice's public value g^a mod pB Bob's public value g^b mod pshared shared secret g^(ab) mod pelgamal_encryptElGamal ciphertext (c1, c2) = (g^k, m h^k) mod p with public key h = g^x.
p the prime modulus integerg the generator integerx the private key integerk the ephemeral exponent integerm the message (1 <= m < p) integerh public key g^x mod pc1 g^k mod pc2 m h^k mod prsa_decryptThe RSA plaintext m = c^d mod n of a ciphertext c.
c the ciphertext (0 <= c < n) integerd private exponent integern modulus integerm plaintext c^d mod nrsa_decrypt_pqDecrypt an RSA ciphertext knowing the primes: compute d, then m by the Chinese remainder theorem.
c the ciphertext (0 <= c < n) integerp first prime integerq second prime integere public exponent integerm the plaintextd private exponent e^(-1) mod phi(n)n modulus p qrsa_encryptThe RSA ciphertext c = m^e mod n of a message number m.
m the message as a number (0 <= m < n) integere public exponent integern modulus integerc ciphertext m^e mod nrsa_keygenThe RSA modulus n = p q, phi(n) = (p-1)(q-1) and the private exponent d = e^(-1) mod phi(n).
p first prime integerq second prime integere public exponent integern modulus p qphi Euler's phi(n) = (p-1)(q-1)d private exponent e^(-1) mod phi(n)vigenere_cipherEncrypt or decrypt with the Vigenère cipher under a keyword.
message the message (letters are kept, everything else is dropped) textkey the keyword (letters) textmode encrypt or decrypt choiceresult the result in capital letters, without spaces or punctuationarticulation_pointsThe vertices whose removal increases the number of connected components.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgescount number of articulation pointspoints the articulation points, ascendingbipartiteWhether the vertices of an undirected graph split into two sets with every edge between them (no odd cycle).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesis_bipartite true when the graph is 2-colourablebfs_orderThe order in which breadth-first search from a source visits the vertices, and each vertex's distance in edges.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgessource the start vertex textdirected true for a directed graph (edges u->v) boolean optionalorder visiting orderreached number of vertices reacheddistances number of edges from the source to each reached vertexbridgesThe edges whose removal increases the number of connected components.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgescount number of bridgesbridges the bridges [u, v] with u < v, sortedchromatic_numberThe fewest colours needed so that adjacent vertices differ, with one optimal colouring.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgeschromatic_number chi(G)colouring an optimal colouring (colours 1..chi)clique_numberThe size of a largest complete subgraph, with one maximum clique.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesclique_number omega(G)clique a maximum clique (the lexicographically smallest), ascendingconnected_componentsThe connected components of an undirected graph: how many, their sizes and members, and whether it is connected.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgescount number of connected componentssizes component sizes, descendingis_connected true when there is one componentcomponents members of each component (ascending), components ordered by their first memberdirected_cycleWhether a directed graph contains a directed cycle (equivalently, whether it is a DAG).
edges the directed graph as edges u->v edgeshas_cycle true when a directed cycle existsis_dag true when the graph is acycliccycle_rankWhether an undirected graph has a cycle, and its cyclomatic number m - n + c (independent cycles).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgescyclomatic_number m - n + c: the number of independent cycleshas_cycle true when the graph contains a cycledfs_orderThe preorder in which depth-first search from a source visits the vertices.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgessource the start vertex textdirected true for a directed graph (edges u->v) boolean optionalorder visiting order (preorder)reached number of vertices reachedgraph_diameterEccentricities of a connected unweighted graph: the diameter (largest), radius (smallest), center and periphery.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesdiameter largest distance between two verticesradius smallest eccentricitycenter vertices of smallest eccentricity (ascending)periphery vertices of largest eccentricity (ascending)eulerianWhether an undirected graph has an Euler circuit (closed trail using every edge once) or an Euler path.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesodd_vertices number of vertices of odd degreeconnected true when the graph is connectedhas_circuit Euler circuit exists: connected and no odd vertexhas_path Euler path exists: connected and 0 or 2 odd verticesgirthThe length of a shortest cycle of an undirected graph (none for a forest).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesgirth length of the shortest cycle (none when the graph is acyclic)graphical_sequenceWhether a list of non-negative integers is the degree sequence of some simple graph.
degrees the proposed degrees (whole numbers >= 0) vectoris_graphical true when a simple graph has exactly these degreeshamiltonian_cycleWhether an undirected graph has a cycle through every vertex exactly once, with one such cycle.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesexists true when a Hamiltonian cycle existscycle a Hamiltonian cycle starting and ending at the smallest vertex (none if it does not exist)independence_numberThe size of a largest set of pairwise non-adjacent vertices, with one maximum independent set.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesindependence_number alpha(G)independent_set a maximum independent set (the lexicographically smallest), ascendingspanning_tree_countHow many spanning trees an undirected simple graph has (0 if it is disconnected).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesspanning_trees number of spanning trees tau(G)graph_trianglesHow many triangles (3-cycles) an undirected graph contains.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgestriangles number of triangleswalks_countHow many walks of exactly k edges lead from u to v (the (u, v) entry of A^k).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgessource start vertex u texttarget end vertex v textlength the walk length k (0..200) integerdirected true for a directed graph (edges u->v) boolean optionalwalks number of walks of length k from u to vprufer_encodeThe Prüfer sequence (length n - 2) of a tree on vertices labelled 1..n.
edges the tree's edges, vertices numbered 1..n (or 0..n-1) edgessequence the Prüfer sequencevertices number of vertices nstrongly_connectedThe strongly connected components of a directed graph (vertices mutually reachable).
edges the directed graph as edges u->v edgescount number of strongly connected componentssizes component sizes, descendingcomponents members of each component (ascending), ordered by first membertopological_sortAn ordering of a directed acyclic graph's vertices in which every edge u->v has u before v.
edges the directed graph as edges u->v edgesorder the lexicographically smallest topological ordervertices number of verticesprufer_decodeThe labelled tree on 1..n (n = length + 2) whose Prüfer sequence is given.
sequence the Prüfer sequence (entries between 1 and n) vectoredges the tree's edges [u, v] with u < v, sortedvertices number of vertices nis_treeWhether an undirected graph is a tree: connected with exactly n - 1 edges (equivalently, connected and acyclic).
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesis_tree true when the graph is a treevertices number of verticesedges number of edgesconnected true when the graph is connectedgraph_degreesThe degree of every vertex of an undirected simple graph, its degree sequence, maximum and minimum degree.
edges the graph as a list of edges u-v (an optional third entry is the weight) edgesvertices number of vertices (those named in the edges)edges number of edgesdegrees degree of each vertexdegree_sequence degrees in descending ordermax_degree maximum degreemin_degree minimum degreelogic_contradictionWhether a formula is false under every assignment (unsatisfiable), with a satisfying assignment if not.
formula the formula (operators ~ & | ^ -> <->, or words) textcontradiction true when no assignment satisfies the formulatrue_rows number of satisfying assignmentswitness the satisfying assignment with the smallest row number (none for a contradiction)logic_evaluateThe truth value of a propositional formula under a given assignment of true/false to its variables.
formula the formula, e.g. (p -> q) & ~r (operators ~ & | ^ -> <->, or not/and/or/xor/implies/iff) textassignment a truth value for every variable, e.g. 'p = true, q = 0, r = false' textvalue the formula's truth valuelogic_equivalenceWhether two formulas have the same truth value under every assignment, with a distinguishing assignment if not.
formula1 the first formula textformula2 the second formula textequivalent true when the formulas agree on every assignmentdiffering_rows number of assignments where they differcounterexample the first distinguishing assignment (none if equivalent)minimal_cnfA minimum conjunctive normal form of a formula: fewest clauses, then fewest literals.
formula the formula (at most 6 variables) textexpression a minimal product of sums (clauses joined by &)clauses number of clausesliterals number of literalsminimal_dnfA minimum disjunctive normal form of a formula: fewest product terms, then fewest literals.
formula the formula (at most 6 variables) textexpression a minimal sum of products (terms joined by |, literals by &)terms number of product termsliterals number of literalsminimal_sop_mintermsThe minimal sum of products of a Boolean function given by its minterms and optional don't-care rows (Karnaugh-map problems).
minterms rows where the function is 1 vectorvariables number of variables (1..6), named A, B, C, ... integerdont_cares rows whose value does not matter (optional) vector optionalexpression a minimal sum of products over A, B, C, ... (A is the most significant bit)terms number of product termsliterals number of literalslogic_satisfiableWhether some assignment makes the formula true, how many do, and the first such assignment.
formula the formula (operators ~ & | ^ -> <->, or words) textsatisfiable true when some assignment satisfies the formulamodels number of satisfying assignmentsfirst_model the satisfying assignment with the smallest row number (none if unsatisfiable)logic_tautologyWhether a formula is true under every assignment, and the first assignment that falsifies it if not.
formula the formula (operators ~ & | ^ -> <->, or words) texttautology true when every assignment satisfies the formulafalse_rows number of falsifying assignmentscounterexample the falsifying assignment with the smallest row number (none for a tautology)truth_tableThe full truth table of a propositional formula, the number of true rows and its minterms.
formula the formula (operators ~ & | ^ -> <->, or words) textvariables the variables in alphabetical ordervalues the formula's value on rows 0, 1, ... as a 0/1 stringtrue_rows number of true rowsminterms indices of the true rowscrtThe x with x ≡ r_i (mod m_i) for every i, unique modulo lcm(m_i); moduli need not be coprime.
residues the residues r_i vectormoduli the moduli m_i (each at least 1) vectorx the smallest non-negative solutionmodulus lcm of the moduli: the solution is unique modulo itdiscrete_logThe smallest x >= 0 with base^x ≡ target (mod m).
base the base g integertarget the value h integermodulus the modulus m (2..10^12) integerx the smallest non-negative exponent with g^x ≡ h (mod m)linear_congruenceAll solutions of a*x ≡ b (mod m): how many there are modulo m, the smallest, and their spacing.
a coefficient of x integerb right-hand side integerm modulus (at least 1) integersmallest smallest non-negative solution (none when there is no solution)count number of solutions modulo m (gcd(a, m) when it divides b, else 0)step m / gcd(a, m): solutions are smallest + k*stepmod_powa^e mod m by repeated squaring (also the last k digits of a power).
base the base a integerexponent the exponent e (at least 0) integermodulus the modulus m (at least 1) integerresult a^e mod m, between 0 and m - 1mod_inverseThe x in 0..m-1 with a*x ≡ 1 (mod m); it exists exactly when gcd(a, m) = 1.
a the integer to invert integerm the modulus (at least 2) integerinverse a^{-1} mod mmultiplicative_orderThe smallest k >= 1 with a^k ≡ 1 (mod n).
a the integer a (coprime to n) integern the modulus (at least 2) integerorder ord_n(a)mod_reducea mod m as the least non-negative residue, with the floor quotient: a = q*m + r, 0 <= r < m.
a the integer to reduce integerm the modulus (at least 1) integerremainder r with 0 <= r < mquotient q = floor(a/m)primitive_rootThe smallest g whose powers run through every non-zero residue modulo the prime p.
p a prime integerroot the smallest primitive root modulo pbase_convertRewrite an integer from one base (2..36) to another, with its decimal value.
digits the number written in the source base (digits 0-9 then A-Z) textfrom_base the source base (2..36) integerto_base the target base (2..36) integerresult the number written in the target base (upper-case digits)decimal its value in base 10twos_complementThe b-bit two's complement bit pattern of a signed integer, and that pattern read as an unsigned number.
n the signed integer integerbits the word length b (2..64) integerbits_text the b-bit patternunsigned the pattern read as an unsigned integer (n mod 2^b)carmichael_lambdalambda(n): the smallest m with a^m ≡ 1 (mod n) for every a coprime to n (the exponent of the unit group).
n a positive integer integerlambda Carmichael's lambda(n)cf_rationalThe finite simple continued fraction [a0; a1, ..., an] of p/q (canonical form: last term >= 2).
numerator the numerator p integerdenominator the denominator q (at least 1) integerterms the partial quotients [a0, a1, ..., an]length number of partial quotientscf_sqrtThe periodic continued fraction sqrt(d) = [a0; (a1, ..., ak)] of a non-square d, and its period length.
d a positive non-square integer integera0 integer part floor(sqrt(d))period the repeating block (ends with 2*a0)period_length length of the perioddivisor_functionsAll positive divisors of n, their number tau(n), their sum sigma(n), and whether n is perfect, abundant or deficient.
n a positive integer integercount number of divisors tau(n)sum sum of divisors sigma(n)proper_sum sum of the proper divisors sigma(n) - nclassification perfect, abundant or deficientdivisors every divisor, ascendingeuler_phiphi(n): how many integers in 1..n are coprime to n.
n a positive integer integerphi Euler's totient phi(n)extended_gcdgcd(a, b) and integers x, y with a*x + b*y = gcd(a, b).
a first positive integer integerb second positive integer integergcd gcd(a, b)x coefficient of a from the extended Euclidean algorithmy coefficient of b from the extended Euclidean algorithmx_min the coefficient of a with 0 <= x_min < b/gcdy_min the matching coefficient of bgcd_lcmThe gcd and lcm of two or more positive integers (Euclid's algorithm).
numbers the positive integers (two or more) vectorgcd greatest common divisorlcm least common multipleinteger_sqrtfloor(sqrt(n)) computed exactly, the remainder n - floor(sqrt(n))^2, and whether n is a perfect square.
n a whole number (at least 0) integerisqrt floor(sqrt(n))remainder n - isqrt^2is_square true when n is a perfect squarejacobi_symbol(a/n) for an odd positive n, the product of Legendre symbols over the prime factors of n.
a the integer a integern an odd positive integer integersymbol the Jacobi symbol (a/n): -1, 0 or 1legendre_symbol(a/p) for an odd prime p: 1 if a is a non-zero quadratic residue mod p, -1 if not, 0 if p divides a.
a the integer a integerp an odd prime integersymbol the Legendre symbol (a/p): -1, 0 or 1linear_diophantineWhether a*x + b*y = c has integer solutions, and the general solution x = x0 + (b/g) t, y = y0 - (a/g) t.
a coefficient of x (non-zero) integerb coefficient of y (non-zero) integerc right-hand side integersolvable true when gcd(a, b) divides cx0 the solution with the smallest non-negative xy0 the matching yx_step b/g: the step of x between solutionsy_step -a/g: the step of y between solutionsmobiusmu(n): 0 if a square divides n, otherwise (-1)^(number of prime factors).
n a positive integer integermu the Möbius function mu(n)squarefree true when no square > 1 divides nnext_primeThe smallest prime strictly greater than n.
n the whole number n (at least 0) integerprime the smallest prime p > npell_equationThe smallest positive solution (x, y) of x^2 - d y^2 = 1 for a non-square d.
d a non-square positive integer (2..1000) integerx fundamental solution xy fundamental solution yprevious_primeThe largest prime strictly less than n.
n the whole number n (at least 3) integerprime the largest prime p < nis_primeWhether n is prime (deterministic Miller-Rabin, exact for every n below 2^64), with its smallest prime factor.
n the whole number to test integeris_prime true when n is primesmallest_prime_factor smallest prime dividing n (n itself when prime; none for n < 2)prime_factorizationThe prime factorization of n, its largest and smallest prime factors and the number of prime factors.
n the whole number to factor (at least 2) integerfactorization list of [prime, exponent] pairs, primes ascendingdistinct_primes number of distinct prime factorsprime_factors_with_multiplicity number of prime factors counted with multiplicitylargest_prime_factor largest prime factorsmallest_prime_factor smallest prime factortext the factorization written as p^e × ...prime_countingpi(x): how many primes are at most x.
x the bound (0..5,000,000) integercount number of primes p <= xsqrt_modEvery x in 0..p-1 with x^2 ≡ a (mod p), for a prime p.
a the integer a integerp a prime modulus integerroots all square roots of a modulo p, ascendingcount number of roots (0, 1 or 2)smallest the smallest root (none when a is a non-residue)two_squaresEvery way to write n = x^2 + y^2 with 0 <= x <= y, and r2(n), the number of ordered signed representations.
n a whole number (0..10^12) integerrepresentations pairs [x, y] with 0 <= x <= y and x^2 + y^2 = ncount number of such pairsr2 r2(n): ordered representations with signsnth_primeThe n-th prime number p_n (p_1 = 2).
n the index n (1..300,000) integerprime the n-th prime| Version | Released |
|---|---|
| 1.0.0 | 2026-10-25 |
15 files, 45.7 MB in total. The largest:
| File | Size |
|---|---|
| model.safetensors | 18.9 MB |
| dist/discrete_math_ai999x-1.0.0-py3-none-any.whl | 18 MB |
| onnx/search/encoder.int8.onnx | 4.9 MB |
| docs/discrete_math_ai999x_capabilities.pdf | 3 MB |
| onnx/search/index.json | 403.3 KB |
| docs/discrete_math_ai999x_capabilities.html | 239 KB |
| onnx/search/tokenizer.json | 176.4 KB |
| docs/discrete_math_ai999x_capabilities.md | 168.9 KB |
| README.md | 20.5 KB |
| LICENSE | 11.4 KB |
| evaluation/release_gate.md | 2.3 KB |
| evaluation/KNOWLEDGE_CARD.md | 1.4 KB |
Discrete Math answers questions in discrete math: number theory, modular arithmetic, combinatorics, graph theory and network algorithms, logic and the mathematics of cryptography. Each answer gives the value with its unit, the steps and the formula in LaTeX.
With pip: pip install discrete-math-ai999x. The same files are on Hugging Face (hf download AI999X/discrete-math-ai999x --local-dir discrete-math-ai999x) and GitHub.
Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.
99 capabilities in 7 topics, including Combinatorics, Graph theory, Number theory, Cryptography, Logic.
Field: Mathematics & Statistics. Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction.
Asked "Find the inverse of 3 modulo 11.", it answers: inverse = 4.
It says so and names what is missing or out of range, instead of guessing a number.