Created
January 14, 2014 17:22
-
-
Save humbhenri/8422123 to your computer and use it in GitHub Desktop.
Champernowne constant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
var champernowne float64 | |
for n := 1; n <= 10; n++ { | |
for k := math.Pow(10.0, float64(n-1)); k < math.Pow(10.0, float64(n)); k++ { | |
var aux float64 | |
for l := 1; l <= n-1; l++ { | |
aux += math.Pow(10.0, float64(l-1)) * float64(l) | |
} | |
champernowne += k / ((math.Pow(10.0, float64(n)*(float64(k)-math.Pow(10.0, float64(n-1))+1)+9*aux))) | |
} | |
} | |
fmt.Println(champernowne) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment