Skip to content

Instantly share code, notes, and snippets.

@angch
Created March 24, 2016 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angch/946192db2ffd1b2edc22 to your computer and use it in GitHub Desktop.
Save angch/946192db2ffd1b2edc22 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/big" // Seems like a copout
)
func main() {
s := big.NewInt(1)
s.Lsh(s, 1000)
base := big.NewInt(10)
mod := big.NewInt(1)
sum := 0
zero := big.NewInt(0)
for s.Cmp(zero) != 0 {
s.DivMod(s, base, mod)
sum += int(mod.Int64())
}
fmt.Println(sum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment