Here is my first try at Google's Go language, trying to solve Project Euler Problem 10:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
Any suggestions on the style and usage (best practice) of Go?
package main
import "fmt"
var primes = []uint64{2, 3}
func CheckIfIsNewPrime(number uint64) bool {
check_if_number_is_new_prime := false
var remainder uint64 = 0
for i := range primes {
remainder = number % primes[i]
if remainder == 0 {
check_if_number_is_new_prime = false
break
} else {
check_if_number_is_new_prime = true
}
}
return check_if_number_is_new_prime
}
func FindNewPrime() uint64 {
for counter := primes[len(primes)-1]; ; counter += 2 {
if CheckIfIsNewPrime(counter) == true {
return counter
}
}
return 0
}
func main() {
limit := 2000000
var sum uint64
sum = 5
for i := 2; i < limit; i++ {
primes = append(primes, FindNewPrime())
sum += primes[len(primes)-1]
}
fmt.Println("sum: ", sum)
}