Skip to content

Instantly share code, notes, and snippets.

@tgross
Created November 22, 2019 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgross/c4eb955bd3d4088948f6ccf34843dfdb to your computer and use it in GitHub Desktop.
Save tgross/c4eb955bd3d4088948f6ccf34843dfdb to your computer and use it in GitHub Desktop.
Dummy application for testing Nomad batch workloads
package main
import (
"fmt"
"os"
"strconv"
)
// return list of primes less than N
func sieveOfEratosthenes(N int) (primes []int) {
b := make([]bool, N)
for i := 2; i < N; i++ {
if b[i] == true {
continue
}
primes = append(primes, i)
for k := i * i; k < N; k += i {
b[k] = true
}
}
return
}
func main() {
arg := os.Args[1]
n, _ := strconv.Atoi(arg)
primes := sieveOfEratosthenes(n)
for _, p := range primes {
fmt.Println(p)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment