{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/an-elementary-method-for-fast-modular","title":"An Elementary Method For Fast Modular Exponentiation With Factored Modulus","arxiv_id":"2401.10497","date":"2024-01-19","proceeding":null,"authors":["Anay Aggarwal","Manu Isaacs"],"abstract":"We present a fast algorithm for modular exponentiation when the factorization of the modulus is known. Let $a,n,m$ be positive integers and suppose $m$ factors canonically as $\\prod_{i=1}^k p_i^{e_i}$. Choose integer parameters $t_i\\in [1, e_i]$ for $1\\le i\\le k$. Then we can compute the modular exponentiation $a^n\\pmod{m}$ in $O(\\max(e_i/t_i)+\\sum_{i=1}^k t_i\\log p_i)$ steps (i.e., modular operations). We go on to analyze this algorithm mathematically and programmatically, showing significant asymptotic improvement in specific cases. Specifically, for an infinite family of $m$ we achieve a complexity of $O(\\sqrt{\\log m})$ steps, much faster than the Repeated Squaring Algorithm, which has complexity $O(\\log m)$. Additionally, we extend our algorithm to matrices and hence general linear recurrences. The complexity is similar; with the same setup we can exponentiate matrices in $GL_d(\\mathbb{Z}/m\\mathbb{Z})$ in less than $O(\\max(e_i/t_i)+d^2\\sum_{i=1}^k t_i\\log p_i)$ steps. This improves Fiduccia's algorithm and the results of Bostan and Mori in the case of $\\mathbb{Z}/m\\mathbb{Z}$. We prove analogous results for $\\mathbb{Z}/p^k\\mathbb{Z}$ ring extensions.","url_abs":"https://arxiv.org/abs/2401.10497v4","url_pdf":"https://arxiv.org/pdf/2401.10497v4.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"an-elementary-method-for-fast-modular","repo_url":"https://github.com/misaacs3737/modExp","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":null}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":null,"mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}