返回列表 发帖
  1. Input: an integer n > 1
  2. Let A be an array of Boolean values, indexed by integers 2 to n,
  3. initially all set to true.
  4. for i = 2, 3, 4, ..., while i ≤ n/2:
  5.   if A[i] is true:
  6.     for j = 2i, 3i, 4i, ..., while j ≤ n:
  7.       A[j] = false
  8. Now all i such that A[i] is true are prime.
复制代码

TOP

返回列表