class_docstr: Class to provide helper functions for mathematics and other small things
class_docstr_tok: ["Class","to","provide","helper","functions","for","mathematics","and","other","small","things"]
docstr: Returns the modular inverse of a mod m, or None if it does not exist.
  
  The modular inverse of a is the number a_inv that satisfies the equation
  a_inv * a mod m === 1 mod m
  
  Note: This is a naive implementation, and runtime may be improved in several ways.
  For instance by checking if m is prime to perform a different calculation,
  or by using the extended euclidean algorithm.
docstr_tok: ["Returns","the","modular","inverse","of","a","mod","m",",","or","None","if","it","does","not","exist",".","The","modular","inverse","of","a","is","the","number","a_inv","that","satisfies","the","equation","a_inv","*","a","mod","m","===","1","mod","m","Note",":","This","is","a","naive","implementation",",","and","runtime","may","be","improved","in","several","ways",".","For","instance","by","checking","if","m","is","prime","to","perform","a","different","calculation",",","or","by","using","the","extended","euclidean","algorithm","."]
code: def mod_inv(a: int, m: int) -> Optional[int]:
      """
      Returns the modular inverse of a mod m, or None if it does not exist.
  
      The modular inverse of a is the number a_inv that satisfies the equation
      a_inv * a mod m === 1 mod m
  
      Note: This is a naive implementation, and runtime may be improved in several ways.
      For instance by checking if m is prime to perform a different calculation,
      or by using the extended euclidean algorithm.
      """
      for i in range(1, m):
          if (m * i + 1) % a == 0:
              return (m * i + 1) // a
      return None
  
file_path: Ciphey/ciphey/mathsHelper.py
imports: from collections import OrderedDict
  from string import punctuation
  from typing import Optional
  import logging
  from rich.logging import RichHandler
label_desc: Use image node_id 3 for calling the mathsHelper obj's underlying member method code with example usage: obj.mod_inv(a, m) and returns: None, unknown