Don't print primes

This commit is contained in:
Peter J. Holzer 2021-07-12 21:07:35 +02:00 committed by Peter J. Holzer
parent 27b131c982
commit 7384eaccf6
1 changed files with 0 additions and 11 deletions

View File

@ -14,24 +14,13 @@ func main() {
}
t0 := time.Now()
sieve := make([]bool, n)
col := 0
var found int64
var i int64
i = 2
found++
s := fmt.Sprintf("%d, ", i)
fmt.Print(s)
col += len(s)
for i = 3; i < n; i += 2 {
if !sieve[i] {
found++
s := fmt.Sprintf("%d, ", i)
if col+len(s) > 80 {
fmt.Print("\n")
col = 0
}
fmt.Print(s)
col += len(s)
for j := i * i; j < n; j += 2 * i {
sieve[j] = true
}