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