MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Problem2

Function Problem2

project_euler/problem_2/problem2.go:17–30  ·  view source on GitHub ↗
(n uint)

Source from the content-addressed store, hash-verified

15package problem2
16
17func Problem2(n uint) uint {
18 sum := uint(0)
19 a, b := uint(1), uint(2)
20
21 for b < n {
22 if b%2 == 0 {
23 sum += b
24 }
25
26 a, b = b, a+b
27 }
28
29 return sum
30}

Callers 2

TestProblem2_FuncFunction · 0.85
BenchmarkProblem2Function · 0.85

Calls

no outgoing calls

Tested by 2

TestProblem2_FuncFunction · 0.68
BenchmarkProblem2Function · 0.68