Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/databases/cunningham_tables.py
8814 views
1
import os
2
from sage.misc.cachefunc import cached_function
3
from sage.rings.integer import Integer
4
from sage.structure.sage_object import load
5
from sage.misc.misc import SAGE_SHARE
6
7
@cached_function
8
def cunningham_prime_factors():
9
"""
10
List of all the prime numbers occuring in the so called Cunningham table.
11
They occur in the factorization of numbers of type $b^n+1$ or $b^n-1$ with $b \in \{2,3,5,6,7,10,11,12\}$.
12
Data from http://cage.ugent.be/~jdemeyer/cunningham/
13
"""
14
file = os.path.join(SAGE_SHARE,'cunningham_tables','cunningham_prime_factors.sobj')
15
if os.path.exists(file):
16
return map(Integer,load(file))
17
else:
18
from warnings import warn
19
warn("You might consider installing the optional package for factoring Cunningham numbers with the following command: ``sage -i cunningham_tables``")
20
return []
21
22
23
24