Example #1
0
func main() {
	starttime := time.Now()

	last := 0
	for i := 65000000; i > 0; i-- {
		set := euler.SplitSeq(length, i)
		if set[0] != last {
			last = set[0]
			fmt.Println(last)
		}

		if isSpecial(set) {
			fmt.Println(set, sum(set))

		}
	}

	fmt.Println("Elapsed time:", time.Since(starttime))
}
Example #2
0
func test(repeat string, n, d int) (N int, S int64) {

	for i := 0; int64(i) < euler.Choose(int64(n), int64(d)); i++ {
		indices := euler.SplitSeq(d, i)

		for j := 0; int64(j) < euler.IntExp(10, int64(d)); j++ {
			insertstring := strconv.Itoa(j)
			for len(insertstring) < d {
				insertstring = "0" + insertstring
			}

			merged := ""
			current := 0
			for index := 0; index < n; index++ {
				if current < d && index == indices[d-current-1] {
					merged += insertstring[current : current+1]
					current++
				} else {
					merged += repeat
				}
			}

			mergedint, _ := strconv.ParseInt(merged, 10, 64)

			//exclude leading zeroes
			if mergedint > euler.IntExp(10, int64(n)-1) {

				if euler.IsPrime(mergedint) {
					//fmt.Println(mergedint)
					N++
					S += mergedint
				}
			}
		}
	}
	return
}