Skip to content

Instantly share code, notes, and snippets.

@primus-lab
primus-lab / chebyshev.py
Last active October 28, 2019 10:15
Primality test using Chebyshev polynomials of the first kind
# Authors: Peter Taylor and Pedja Terzic
import sys
print(" ***** CHEBYSHEV *****\n\n\n")
while True:
n=int(input("Enter a number : "))
@primus-lab
primus-lab / T261.py
Created October 28, 2019 09:42
Primality tests for numbers of the form N=2*6^n-1 and N=2*6^n+1
'''
This script was written in python 3.x.
In order to run this script, please make sure your python version is 3.x or above.
How to run:
python T261.py
or if it doesn't work use this one:
python3 T261.py
Author: Pedja Terzic <[email protected]>
'''
@primus-lab
primus-lab / fermat.py
Created October 30, 2019 08:07
Primality test for generalized Fermat numbers
'''
This script was written in python 3.x.
In order to run this script, please make sure your python version is 3.x or above.
How to run:
python fermat.py
or if it doesn't work use this one:
python3 fermat.py
Author: Pedja Terzic <[email protected]>
'''
@primus-lab
primus-lab / cardano.py
Last active December 31, 2019 07:50
Probabilistic primality test
# Author: Pedja
import random
print(" ***** CARDANO *****\n\n\n")
while True:
n=int(input("Enter a number : "))
k=int(input("Enter an accuracy parameter : "))
@primus-lab
primus-lab / mersenne.py
Last active December 31, 2019 07:49
Conjectured primality test for numbers of the form M=k*b^n-1
# Author: Pedja
from mpmath import *
print(" ***** MERSENNE *****\n\n\n")
while True:
k=int(input("Enter the coefficient : "))
b=int(input("Enter the base : "))
@primus-lab
primus-lab / cop.py
Last active December 31, 2019 07:48
Conjectured primality test
# Author: Pedja
print(" ***** COP *****\n\n\n")
while True:
n=int(input("Enter a number : "))
@primus-lab
primus-lab / protos.py
Last active December 31, 2019 07:47
Prime number generator.
# Author: Pedja
print(" ***** PROTOS *****\n\n\n")
while True:
n=int(input("Enter the ordinal number : "))
@primus-lab
primus-lab / sieve.py
Created January 2, 2020 08:58
Prime number sieve using LCM function
# Author: Pedja
print(" ***** SIEVE *****\n\n\n")
while True:
n1=int(input("Enter lower bound : "))
@primus-lab
primus-lab / lux.py
Created January 3, 2020 09:23
Compositeness test for numbers of the form N=k*b^n+c
# Author: Pedja
from mpmath import *
from sympy import *
print(" ***** LUX *****\n\n\n")
while True:
@primus-lab
primus-lab / safeprime.py
Created January 5, 2020 08:08
Primality test for numbers of the form N=2*p+1
# Author: Pedja
from sympy import *
print(" ***** SAFE PRIME *****\n\n\n")
while True: