Created
May 11, 2015 08:06
-
-
Save sguzman/fcf8b9362258f2f13c0f to your computer and use it in GitHub Desktop.
factor 27^140... of course, its only prime factor is 3
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/big" | |
//util "github.com/cznic/mathutil" | |
) | |
func Copy(from *big.Int) (*big.Int) { | |
stubby := big.NewInt(1) | |
stubby.SetString(from.String(), 10) | |
return stubby | |
} | |
func main() { | |
factors := make(map[uint64]uint64) | |
index := big.NewInt(4) | |
index.Exp(big.NewInt(27), big.NewInt(140), nil) | |
//limit := util.SqrtBig(index) | |
div := big.NewInt(1) | |
mod := big.NewInt(1) | |
zero := big.NewInt(0) | |
one := big.NewInt(1) | |
for i := big.NewInt(2); i.Cmp(big.NewInt(100)) < 0; { | |
div.DivMod(index, i, mod) | |
fmt.Println("index: ", index, ", i: ", i) | |
fmt.Println("mod: ", mod) | |
if mod.Cmp(zero) == 0 { | |
factors[i.Uint64()] += 1 | |
index.SetString(div.String(), 10) | |
i = big.NewInt(2) | |
} else { | |
i.Add(i, one) | |
} | |
} | |
fmt.Println(factors) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment