// Euler3 solution func Euler3(l int) []int { allFactors := goutils.GetFactors(l) var primeFactors []int for i := 0; i < len(allFactors); i++ { if goutils.IsPrime(allFactors[i]) { primeFactors = append(primeFactors, allFactors[i]) } } return primeFactors }
//Euler12 is the solution to 12 func Euler12(l int) int { nums := goutils.TriangleNumber(l) for i := 0; i < len(nums); i++ { if !goutils.IsPrime(nums[i]) { factors := goutils.GetFactors(nums[i]) if len(factors) == 499 { return nums[i] } } } return 0 }
// TestGetFactors tests the GetFactors func TestGetFactors(t *testing.T) { var tt = []goutils.TTIA{ {10, []int{2, 5}}, } for i := 0; i < len(tt); i++ { testIn := goutils.GetFactors(tt[i].Test) testExp := tt[i].Expt if goutils.ArrayEqual(testExp, testIn) { t.SkipNow() } else { t.Error("Test failed") } } }