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

Function weightNextNode

project_euler/problem_14/problem14.go:42–56  ·  view source on GitHub ↗
(current uint64)

Source from the content-addressed store, hash-verified

40}
41
42func weightNextNode(current uint64) uint64 {
43 var next, weight uint64
44 if current%2 == 0 {
45 next = current / 2
46 } else {
47 next = (3 * current) + 1
48 }
49 if v, ok := dictionary[next]; !ok {
50 weight = weightNextNode(next) + 1
51 } else {
52 weight = v + 1
53 }
54 dictionary[current] = weight
55 return weight
56}

Callers 1

Problem14Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected