Example #1
0
File: p10.go Project: ridha/euler
func generate_prime(start int64, end int64, c chan int64) {
	for i := start; i < end; i += 2 {
		if helpers.IsPrime(i) {
			c <- i
		}
	}
	close(c)
}
Example #2
0
File: p3.go Project: ridha/euler
func main() {
	const num int64 = 600851475143
	var i int64 = helpers.Sqrt(num)
	for ; i > 1; i-- {
		if num%i == 0 && helpers.IsPrime(i) {
			fmt.Println(i)
			break
		}
	}
}
Example #3
0
File: p7.go Project: ridha/euler
func main() {
	count := 0
	var i int64 = 3
	for ; ; i += 2 {
		if helpers.IsPrime(i) {
			count += 1
		}
		if count == 10000 {
			fmt.Println(i)
			break
		}
	}
}