mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 18:34:42 +01:00
29: distinct powers
This commit is contained in:
29
29_distinct_powers/main.go
Normal file
29
29_distinct_powers/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
m := map[string]struct{}{}
|
||||
count := 0
|
||||
for i := 2; i <= 100; i++ {
|
||||
for j := 2; j <= 100; j++ {
|
||||
c := 1
|
||||
p, _ := (&big.Int{}).SetString(strconv.Itoa(1), 0)
|
||||
t, _ := (&big.Int{}).SetString(strconv.Itoa(i), 0)
|
||||
for c <= j {
|
||||
p = p.Mul(p, t)
|
||||
c++
|
||||
}
|
||||
fmt.Println(i, j, p.String())
|
||||
count++
|
||||
if _, ok := m[p.String()]; !ok {
|
||||
m[p.String()] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("len:", len(m), "count:", count)
|
||||
}
|
||||
Reference in New Issue
Block a user