mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 23:04:42 +01:00
63: powerful digit counts
This commit is contained in:
22
63_powerful_digit_counts/main.go
Normal file
22
63_powerful_digit_counts/main.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := 0.
|
||||
for n := 1.; n <= 9.; n++ {
|
||||
c += math.Floor(math.Ln10 / math.Log(10/n))
|
||||
}
|
||||
fmt.Println("solution=", c)
|
||||
}
|
||||
|
||||
func nPower(n, num int) int64 {
|
||||
p := int64(1)
|
||||
for i := 0; i < n; i++ {
|
||||
p *= int64(num)
|
||||
}
|
||||
return p
|
||||
}
|
||||
Reference in New Issue
Block a user