Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Super-d-numbers/Go/super-d-numbers.go
Normal file
35
Task/Super-d-numbers/Go/super-d-numbers.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
start := time.Now()
|
||||
rd := []string{"22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"}
|
||||
one := big.NewInt(1)
|
||||
nine := big.NewInt(9)
|
||||
for i := big.NewInt(2); i.Cmp(nine) <= 0; i.Add(i, one) {
|
||||
fmt.Printf("First 10 super-%d numbers:\n", i)
|
||||
ii := i.Uint64()
|
||||
k := new(big.Int)
|
||||
count := 0
|
||||
inner:
|
||||
for j := big.NewInt(3); ; j.Add(j, one) {
|
||||
k.Exp(j, i, nil)
|
||||
k.Mul(i, k)
|
||||
ix := strings.Index(k.String(), rd[ii-2])
|
||||
if ix >= 0 {
|
||||
count++
|
||||
fmt.Printf("%d ", j)
|
||||
if count == 10 {
|
||||
fmt.Printf("\nfound in %d ms\n\n", time.Since(start).Milliseconds())
|
||||
break inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue