// 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 }
// TestIsPrime tests the IsPrime function func TestIsPrime(t *testing.T) { var tt = []goutils.TTIB{ {2, true}, {5, true}, {4, false}, {9, false}, } for i := 0; i < len(tt); i++ { testIn := goutils.IsPrime(tt[i].Test) testExp := tt[i].Expt if testExp != testIn { t.Error("IsPrime test failed") } } }