(current uint64)
| 40 | } |
| 41 | |
| 42 | func 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 | } |