func (this *Sum) Init(newElements vector.IntVector) { this.elements = newElements.Copy() this.accumulated = 0 for _, v := range this.elements { this.accumulated += v } }
func recursive(in int64, value *big.Int, v vector.IntVector, primeIndex int, primes []*big.Int, winner *big.Int, winner2 *vector.IntVector) { if in > 4000000 { if value.Cmp(winner) < 0 || winner.Cmp(big.NewInt(-1)) == 0 { winner.Set(value) *winner2 = v fmt.Println(in, winner, *winner2) //fmt.Print(in, winner, *winner2, " (") //for k, v := range *winner2 { // fmt.Print(primes[k], "**", v, " * ") //} //fmt.Println(")") } return } for i := int64(15); i >= 1; i -= 1 { var factor big.Int factor.Exp(primes[primeIndex], big.NewInt(i), nil) //fmt.Println(factor, i, primes[primeIndex]) newV := v.Copy() newV.Push(int(i)) var newValue big.Int newValue.Mul(value, &factor) recursive(in*(2*i+1)-i, &newValue, newV, primeIndex+1, primes, winner, winner2) } }
func (this *Sum) Init(newElements vector.IntVector) { this.elements = newElements.Copy() }
func (this *Sum) Init2(newElements vector.IntVector, newAccumulated int) { this.elements = newElements.Copy() this.accumulated = newAccumulated }