xah talk show 2019-03-30

package main

// write a program that prints the first 100 prime numbers

import "fmt"

func main() {

	var max = 600

	var nonprime = map[int]bool{}

	for j := 2; j < 100; j++ {
		for i := 2; i <= max; i++ {
			var x = j * i
			if x < max {
				nonprime[x] = true
			}
		}
	}

	for i := 0; i < max; i++ {
		var _, b = nonprime[i]
		if !b {
			fmt.Printf("%v\n", i)
		}
	}
}

If you have a question, put $5 at patreon and message me.