def testRabinMiller(self): # https://fr.wikipedia.org/wiki/Nombre_premier#Historique_du_plus_grand_nombre_premier_connu self.assertTrue(tp2.rabin_miller(131071)) self.assertTrue(tp2.rabin_miller(170141183460469231731687303715884105727)) self.assertTrue(tp2.rabin_miller(20988936657440586486151264256610222593863921)) self.assertFalse(tp2.rabin_miller(20988936657440586486151264256610222593863923)) self.assertFalse(tp2.rabin_miller(20988936657440586486151264256610222593863922)) self.assertTrue(tp2.rabin_miller(pow(2, 1279) - 1)) self.assertFalse(tp2.rabin_miller(1022))
def testGenerationPremier(self): self.assertRaises(Exception, tp2.generer_nombre_premier(10)) self.assertTrue(tp2.rabin_miller(tp2.generer_nombre_premier(1024))) self.assertFalse(tp2.rabin_miller(tp2.generer_nombre_premier(1024) + 1))