Skip to content

Instantly share code, notes, and snippets.

@humbhenri
Last active January 3, 2016 06:29
Show Gist options
  • Save humbhenri/8422711 to your computer and use it in GitHub Desktop.
Save humbhenri/8422711 to your computer and use it in GitHub Desktop.
Project Euler Problem 40
package main
import (
"bytes"
"fmt"
"strconv"
)
func main() {
var champernowne bytes.Buffer
n := 1
max := 1000000
for champernowne.Len() < max {
number := strconv.Itoa(n)
champernowne.WriteString(number)
n += 1
}
cham := champernowne.String()
result := 1
for i := 1; i <= 1000000; i *= 10 {
result *= int(cham[i-1] - 48)
}
fmt.Println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment