现在的位置: 首页 > 综合 > 正文

Test Prime Using Fermat’s Little Theorem

2019年03月11日 ⁄ 综合 ⁄ 共 1155字 ⁄ 字号 评论关闭

;Fermat's little theorem

 

;If N is a prime number and A is any positive number less than N, then (A^N % N) == (A % N). (A^N stands for A raised to the Nth power.)

 

;This theorem can be used to test the primality of a number. If the above relation is not satisfied for a N, then N is certainly not a prime. If the above relation is satisfied for a N, then the chance is good that N is a prime. The equation is necessary for N to be a prime, but it is not sufficient.

 

;The programs followed are a implementation for testing the primality of a N.

 

抱歉!评论已关闭.