示例#1
0
// Euler10 solution
func Euler10(n int) int {
	set := goutils.PrimeLimit(n)
	sum := 0
	for i := 0; i < len(set); i++ {
		sum += set[i]
	}
	return sum
}
func TestPrimeLimit(t *testing.T) {
	var tt = []goutils.TTIA{
		{20, []int{2, 3, 5, 7, 11, 13, 17, 19}},
		{10, []int{2, 3, 5, 7}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := goutils.PrimeLimit(tt[i].Test)
		testExp := tt[i].Expt

		if goutils.ArrayEqual(testExp, testIn) == false {
			t.Error("PrimeLimit test failed")
		}
	}
}