Created
March 5, 2019 13:32
-
-
Save LordRahl90/862e68b5a2e113156a79937a9852b3fa to your computer and use it in GitHub Desktop.
10001's Prime Number, Project Euler #7
This file contains 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" | |
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