Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
15
package
problem2
16
17
func
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_Func
Function · 0.85
BenchmarkProblem2
Function · 0.85
Calls
no outgoing calls
Tested by
2
TestProblem2_Func
Function · 0.68
BenchmarkProblem2
Function · 0.68