Example #1
0
func isRightTruncatablePrime(n int) bool {
	for n != 0 {
		if !utils.IsPrime(n) {
			return false
		}
		n /= 10
	}
	return true
}
Example #2
0
func isLeftTruncatablePrime(n int) bool {
	n = utils.ReverseInt(n)
	for n != 0 {
		if !utils.IsPrime(utils.ReverseInt(n)) {
			return false
		}
		n /= 10
	}
	return true
}
Example #3
0
func E7() (i int) {

	nth := 10001

	for count := 0; count != nth; i++ {
		if utils.IsPrime(i) {
			count++
		}
	}

	return i - 1
}
Example #4
0
func E49() string {

	primes := utils.Primes(10000)
	var a, b, c int

	for i := 0; i < len(primes); i++ {
		for j := i + 1; j < len(primes); j++ {
			if utils.ArePermutations(primes[i], primes[j]) {
				k := 2*primes[j] - primes[i]
				if utils.IsPrime(k) && utils.ArePermutations(primes[i], k) {
					a, b, c = primes[i], primes[j], k
				}
			}
		}
	}

	return fmt.Sprintf("%d%d%d", a, b, c)
}