MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / Problem16

Function Problem16

project_euler/problem_16/problem16.go:17–33  ·  view source on GitHub ↗
(exponent int64)

Source from the content-addressed store, hash-verified

15)
16
17func Problem16(exponent int64) int64 {
18 var result big.Int
19
20 bigTwo := big.NewInt(2)
21 bigExponent := big.NewInt(exponent)
22
23 result.Exp(bigTwo, bigExponent, nil)
24
25 resultStr := result.String()
26
27 var sum int64
28 for _, digit := range resultStr {
29 sum += int64(digit - '0')
30 }
31
32 return sum
33}

Callers 2

TestProblem16_FuncFunction · 0.85
BenchmarkProblem16_FuncFunction · 0.85

Calls 1

StringMethod · 0.80

Tested by 2

TestProblem16_FuncFunction · 0.68
BenchmarkProblem16_FuncFunction · 0.68