func E12() (ans int) { limit := 500 primes := utils.Primes(3) for i := 1; ; i++ { if primes[len(primes)-1] <= i+1 { primes = utils.Primes(2 * (i + 1)) } n, d := i*(i+1)/2, 1 for t, j := 0, 0; n != 1; j++ { for t = 0; n%primes[j] == 0; { n /= primes[j] t++ } d *= t + 1 } if d > limit { ans = i * (i + 1) / 2 break } } return ans }
func E3() uint64 { n, res := uint64(600851475143), uint64(0) nf := float64(n) primes := utils.Primes(int(math.Sqrt(nf))) for _, p := range primes { for n%uint64(p) == 0 { n /= uint64(p) res = uint64(p) } } return res }
func E49() string { primes := utils.Primes(10000) var a, b, c int for i := 0; i < len(primes); i++ { for j := i + 1; j < len(primes); j++ { if utils.ArePermutations(primes[i], primes[j]) { k := 2*primes[j] - primes[i] if utils.IsPrime(k) && utils.ArePermutations(primes[i], k) { a, b, c = primes[i], primes[j], k } } } } return fmt.Sprintf("%d%d%d", a, b, c) }
func E124() int { const upto = 100000 primes := utils.Primes(upto) rad := make(TupleArray, upto+1) for i := 1; i <= upto; i++ { rad[i][0], rad[i][1] = i, i } for _, i := range primes { for k := 2; utils.Pow(i, k) <= upto && utils.Pow(i, k) > 0; k++ { for j := utils.Pow(i, k); j <= upto; j += utils.Pow(i, k) { rad[j][1] /= i } } } sort.Sort(rad) return rad[10000][0] }