You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
632 B

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

筛选法
  显然以上的枚举法不管如何改进都是不能AC的所以枚举法肯定是行不通的。
  用筛法求素数的基本思想是把从1开始的、某一范围内的正整数从小到大顺序排列 1不是素数首先把它筛掉。剩下的数中选择最小的数是素数然后去掉它的倍数。依次类推直到筛子为空时结束。如有1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  1不是素数去掉。剩下的数中2最小是素数去掉2的倍数余下的数是
  3 5 7 9 11 13 15 17 19 21 23 25 27 29
  剩下的数中3最小是素数去掉3的倍数如此下去直到所有的数都被筛完求出的素数为
  2 3 5 7 11 13 17 19 23 29
判断一个数是不是质数(素数)3种方式介绍