Skip to content

Instantly share code, notes, and snippets.

View andersonaddo's full-sized avatar
😑
Simultaneously tortured and motivated by boredom.

Anderson Addo andersonaddo

😑
Simultaneously tortured and motivated by boredom.
View GitHub Profile
@andersonaddo
andersonaddo / BailliePSWForJava.java
Last active June 15, 2019 11:57
A Java implimentation of the Baillie-PSW algorithm. Translated from @smllmn's repo https://github.com/smllmn/baillie-psw. Check that repo's issues section for info on some possible improvements.
import java.util.BitSet;
public class BailliePSWForJava {
public static boolean baillie_psw(long candidate){
//Perform the Baillie-PSW probabilistic primality test on candidateS
//Check divisibility by a short list of primes less than 50
for (long known_prime : new long []{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}){
if (candidate == known_prime)