package main import ( "fmt" "math/big" ) func main() { base := big.NewInt(2) exp := big.NewInt(10) result := new(big.Int).Exp(base, exp, nil) fmt.Printf("%v^%v = %v\n", base, exp, result) }
2^10 = 1024
package main import ( "fmt" "math/big" ) func main() { base := new(big.Int) base.SetString("123456789876543210", 10) exp := new(big.Int) exp.SetString("987654321012345678", 10) result := new(big.Int).Exp(base, exp, nil) fmt.Printf("%v^%v = %v\n", base, exp, result) }
123456789876543210^987654321012345678 = 393939227123020995616785377891756973662919619698388027812010440442960831573313331312783730785345504529595853144905088321286647585370182604058480411653800446691073221136861632555871965998918304169646198012097769507390257069078800758364166872378334387850042569320141033881511619977125956847044018347001637898429710322502394705590057024401396506927957242391482344912231522080732675670368352767422971931135959668319404790305148587173370821827908644835283594342138008474041703886700102729402181530583021648389630863255448051711125280732991561979936808468637906510761794368253296666453859814107405315580611990786944273706662867179175998144422964795743968620853437605751581078757503294753301922119277974383053011689780633335836128787980947198528279245332905239160518655879724884043065701832054950128822717925340349029586052731862985387816329487334298100991954841355153531717012011482112191781835594233955398357768776580796936931413817901565478452845997714715321564968000339971316820057024384979139723874636164425543812663486799195277353840369305122331862073319240529521794303158771240303819758185231045238838055416864066798260083883506377526197875897778102735863174180772",Package Library: math/big