摘要: Description Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and 阅读全文
posted @ 2019-09-04 21:15 白菜茄子 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 素数筛:需要一个数组进行标记 最小的素数2,所有是2的倍数的数都是合数,对合数进行标记,然后找大于2的第一个非标记的数(肯定是素数),将其倍数进行标记,如此反复,若是找n以内的所有素数,只需要对[2,n^0.5]进行循环即可,因为n以内的所有数如果不是[2,n^0.5]的倍数,则一定是素数。复杂度: 阅读全文
posted @ 2019-09-04 11:29 白菜茄子 阅读(179) 评论(0) 推荐(0) 编辑