Python 是否存在素数相关函数的库? [英] Does a library for prime-related functions exist for Python?

查看:82
本文介绍了Python 是否存在素数相关函数的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚实施了 Miller-Rabin-Test 和一个简单的数字因式分解函数.两者都可以做得更好,至少米勒-拉宾测试是众所周知的.

I've just implemented the Miller-Rabin-Test and a simple function for factorizing numbers. Both could be done better and at least the Miller-Rabin-Test is well-known.

那么请您告诉我是否存在实现此类常见素数函数的 Python 库,或者为什么不存在此类库?

So could you please tell me if a Python-Library, that implements such common prime functions exists or why no such library exists?

推荐答案

gmpy2 支持多种伪素数测试.Miller-Rabin 测试可作为 gmpy2.is_strong_prp​​() 使用.

gmpy2 supports a variety of pseudoprime tests. The Miller-Rabin test is available as gmpy2.is_strong_prp().

gmpy2 还没有任何分解代码.

gmpy2 does not have any factorization code yet.

免责声明:我是 gmpy2 的维护者.素性测试基于 http://sourceforge.net/projects/mpzprp/files/

Disclaimer: I'm the maintainer of gmpy2. The primality tests are based on code from http://sourceforge.net/projects/mpzprp/files/

这篇关于Python 是否存在素数相关函数的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆