Created
November 22, 2019 16:14
-
-
Save tgross/c4eb955bd3d4088948f6ccf34843dfdb to your computer and use it in GitHub Desktop.
Dummy application for testing Nomad batch workloads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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