# coleifer/project-euler

### Subversion checkout URL

You can clone with
or
.

# Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

# Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
• 2 commits
• 2 files changed
• 1 contributor
Commits on Apr 27, 2012
 coleifer `Solving 20 using the big package` `8941026` coleifer `Solving problem 21` `9df60a7`
Showing with 49 additions and 0 deletions.
1. +16 −0 go/problem20.go
2. +33 −0 go/problem21.go
16 go/problem20.go
 @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + n := new(big.Int) + n.MulRange(1, 100) + sum := 0 + for _, d := range(n.String()) { + sum += int(d) - int('0') + } + fmt.Printf("%v\n", sum) +}
33 go/problem21.go
 @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "math" +) + +func divisor_sum(n int) int { + sum := 1 // all numbers are divisible by 1 + nsqrt := int(math.Ceil(math.Sqrt(float64(n)))) + for i := 2; i <= nsqrt; i++ { + if n % i == 0 { + sum += i + if i != nsqrt { + sum += n / i + } + } + } + return sum +} + +const COUNT = 10000 + +func main() { + total := 0 + for i := 1; i < COUNT; i++ { + di := divisor_sum(i) + if di != i && i == divisor_sum(di) { + total += i + } + } + fmt.Printf("%v\n", total) +}

### No commit comments for this range

Something went wrong with that request. Please try again.