Skip to content

Instantly share code, notes, and snippets.

@LordRahl90
Created March 5, 2019 13:32
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 LordRahl90/862e68b5a2e113156a79937a9852b3fa to your computer and use it in GitHub Desktop.
Save LordRahl90/862e68b5a2e113156a79937a9852b3fa to your computer and use it in GitHub Desktop.
10001's Prime Number, Project Euler #7
package main
import "fmt"
func solution(index int) int {
num, counter, val := 2, 0, 0
for {
var clean = true
for i := 2; i <= num-1; i++ {
if num%i == 0 {
clean = false
break
}
}
if clean {
counter++
fmt.Println("Counter is: ", counter)
} else {
fmt.Println("Num not clean ", num)
}
if counter >= index {
val = num
break
}
num++
}
return val
}
func main() {
index := 10001
val := solution(index)
fmt.Printf("The %d Prime number is: %d\n", index, val)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment