Skip to content

Instantly share code, notes, and snippets.

@EdamAme-x
Created October 9, 2024 08:29
Show Gist options
  • Save EdamAme-x/e37694983db2801d23779ca40018b703 to your computer and use it in GitHub Desktop.
Save EdamAme-x/e37694983db2801d23779ca40018b703 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/big"
)
func main() {
maxA := 100000
maxN := 100
factorialA := big.NewInt(1)
for a := 1; a <= maxA; a++ {
if a > 1 {
factorialA.Mul(factorialA, big.NewInt(int64(a-1)))
}
for n := 1; n <= maxN; n++ {
powAN := new(big.Int).Exp(big.NewInt(int64(a)), big.NewInt(int64(n-1)), nil)
sumFactorialA := new(big.Int).Add(factorialA, big.NewInt(1))
if sumFactorialA.Cmp(powAN) == 0 {
fmt.Printf("a = %d, n = %d\n", a, n)
}
}
}
}
@EdamAme-x
Copy link
Author

A≦100000 && N≦100 結果

a = 2, n = 2
a = 3, n = 2
a = 5, n = 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment