-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem0010.go
More file actions
36 lines (25 loc) · 674 Bytes
/
problem0010.go
File metadata and controls
36 lines (25 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @link Problem definition [[docs/projecteuler/problem0010.md]]
*/
package projecteuler
import (
"gon.cl/algorithms/exercises/projecteuler/helpers"
"gon.cl/algorithms/utils/log"
)
func Problem0010(bottom, top int) int {
var answer int
var primes = []int{2}
var i = bottom
for i <= top {
if helpers.IsPrime(i) {
primes = append(primes, i)
log.Debug("Prime found %d put in position: %d", i, len(primes))
}
i += 2
}
answer = helpers.Sum(primes)
log.Info("primes count: %d", len(primes))
log.Info("Sum of primes below ${top} is: ${sum(primes)}")
log.Info("Problem0010 answer => Sum of primes below %d = %d", top, answer)
return answer
}