Пример #1
0
/*
Solve003 solves Project Euler 003
*/
func Solve003() (ans int) {
	m := peb.PrimeFactorization(600851475143)
	for k := range m {
		ans = peb.MaxInt(ans, k)
	}
	return
}
Пример #2
0
/*
Solve005 solves Project Euler 005
*/
func Solve005() (ans int) {
	all := make(map[int]int)
	for i := 2; i <= 20; i++ {
		m := peb.PrimeFactorization(i)
		for k, v := range m {
			if _, ok := all[k]; ok {
				all[k] = peb.MaxInt(all[k], v)
			} else {
				all[k] = v
			}
		}
	}
	ans = 1
	for k, v := range all {
		for i := 0; i < v; i++ {
			ans *= k
		}
	}
	return
}