Seventeen

Today it is the first day of July in the year 2017. On this day there is a point in time which can be represented as 1.7.2017, 17:17:17.
To celebrate this symbolically speaking 17-heavy day, I created a list of 17 integer sequences which all contain the number 17.
All sequences were generated using a Python program; the source code can be viewed below or downloaded. Because the following list is formatted using LaTex, the program’s plaintext output can also be downloaded.

  1. Prime numbers n.
    \{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, \dots\}
  2. Odd positive integers n whose number of goldbach sums (all possible sums of two primes) of n+1 and n-1 are equal to one another.
    \{5, 7, 15, 17, 19, 23, 25, 35, 75, 117, 177, 207, 225, 237, 321, 393, 453, 495, 555, 567, \dots\}
  3. Positive integers n who are part of a Pythagorean triple excluding 0: n^2=a^2+b^2 with integers a,b>0.
    \{5, 10, 13, 15, 17, 20, 25, 26, 29, 30, 34, 35, 37, 39, 40, 41, 45, 50, 51, 52, \dots\}
  4. Positive integers n where \lfloor (n!)^{\frac{1}{n}} \rfloor is prime
    \{4, 5, 6, 7, 8, 12, 13, 17, 18, 19, 28, 29, 33, 34, 35, 44, 45, 46, 49, 50, \dots\}
  5. Positive integers n with distance 1 to a perfect square.
    \{1, 2, 3, 5, 8, 10, 15, 17, 24, 26, 35, 37, 48, 50, 63, 65, 80, 82, 99, 101, \dots\}
  6. Positive integers n where the number of perfect squares including 0 less than n is prime.
    \{2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 37, 38, 39, \dots\}
  7. Prime numbers n where either n-2 or n+2 (exclusive) are prime.
    \{3, 7, 11, 13, 17, 19, 29, 31, 41, 43, 59, 61, 71, 73, 101, 103, 107, 109, 137, 139, \dots\}
  8. Positive integers n whose three-dimensional vector’s (n, n, n) floored length is prime, \lfloor \sqrt{3 \cdot n^2} \rfloor is prime.
    \{2, 3, 8, 10, 11, 17, 18, 24, 25, 31, 39, 41, 46, 48, 60, 62, 63, 76, 91, 100, \dots\}
  9. Positive integers n who are the sum of a perfect square and a perfect cube (excluding 0).
    \{2, 5, 9, 10, 12, 17, 24, 26, 28, 31, 33, 36, 37, 43, 44, 50, 52, 57, 63, 65, \dots\}
  10. Positive integers n whose decimal digit sum is the cube of a prime.
    \{8, 17, 26, 35, 44, 53, 62, 71, 80, 107, 116, 125, 134, 143, 152, 161, 170, 206, 215, 224, \dots\}
  11. Positive integers n for which \text{decimal\_digitsum}(n)+n is a perfect square.
    \{2, 8, 17, 27, 38, 72, 86, 135, 161, 179, 216, 245, 275, 315, 347, 432, 467, 521, 558, 614, \dots\}
  12. Prime numbers n for which \text{decimal\_digitsum}(n^4) is prime.
    \{2, 5, 7, 17, 23, 41, 47, 53, 67, 73, 97, 103, 113, 151, 157, 163, 173, 179, 197, 199, \dots\}
  13. Positive integers n where decimal_digitsum(2 \cdot n) is a substring of n.
    \{9, 17, 25, 52, 58, 66, 71, 85, 90, 104, 107, 115, 118, 123, 137, 142, 151, 156, 165, 170, \dots\}
  14. Positive integers n whose decimal reverse is prime.
    \{2, 3, 5, 7, 11, 13, 14, 16, 17, 20, 30, 31, 32, 34, 35, 37, 38, 50, 70, 71, \dots\}
  15. Positive integers n who are a decimal substring of n^n.
    \{1, 5, 6, 9, 10, 11, 16, 17, 19, 21, 24, 25, 28, 31, 32, 33, 35, 36, 37, 39, \dots\}
  16. Positive integers n whose binary expansion has a prime number of 1‘s.
    \{3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, \dots\}
  17. Positive integers n whose 7-segment representation uses a prime number of segments.
    \{1, 2, 3, 5, 7, 8, 12, 13, 15, 17, 20, 21, 26, 29, 30, 31, 36, 39, 47, 48, \dots\}

# Python 2.7.7 Code
# Jonathan Frech, 29th, 30th  of June 2017

# length of sequences
N = 20

# test if n is prime
def prime(n):
	for d in range(2, int(n)):
		if n%d == 0: return False
	return n > 1 and n%1 == 0

# n's decimal digit sum
def decimal_digitsum(n): return sum(map(int, str(n)))

# square, cube root
def sqrt(n): return n**(1/2.)
def cbrt(n): return n**(1/3.)

# floor, ceil
def floor(n): return int(n)
def ceil (n): return int(n)+(n%1 != 0)

# perfect square, cube
def issqr(n): return sqrt(n)%1 == 0
def iscub(n): return cbrt(n)%1 == 0

# count all unique ways to express n as a sum of two primes (n >= 4 has to be even)
def gold(n):
	if n % 2 != 0: return 0
	if n     == 4: return 1
	g = set()
	for a in range(n):
		for b in range(n):
			if a+b == n and prime(a) and prime(b): g.add((min(a,b), max(a,b)))
	return len(g)

# n^2=a^2+b^2 with integers a,b,n>0
def pythagorean(n):
	for a in range(1, n):
		for b in range(1, n):
			if a**2+b**2 == n**2: return True
	return False

# factorial of n; n!
def fac(n): return 1 if n <= 0 else n*fac(n-1)

# unique ways to express n as sum of two positive integers
def twosum(n):
	g = set()
	for a in range(1, n):
		for b in range(1, n):
			if a+b==n:g.add((min(a, b), max(a, b)))
	return g

# number of perfect squares less than n (including 0^2)
def numsqr(n):
	S = 0
	for s in range(n):
		if issqr(s): S += 1
	return S

# positive integers who are the sum of a square and cube
def sumsqrcub(n):
	for s in range(1, n):
		for c in range(1, n):
			if issqr(s) and iscub(c) and s+c == n: return True

# number of segments a 7-segment representation of positive integer n uses
def sevenseg(n): return sum(map(lambda x: (6, 2, 5, 5, 4, 5, 6, 3, 7, 6)[int(x)], str(n)))

# defined sequences
sequences = [
	
	("Prime numbers n."                                                                                                              , lambda n: prime(n)),
	("Odd positive integers n whose number of goldbach sums (all possible sums of two primes) of n+1 and n-1 are equal to one another.", lambda n: 0 != gold(n-1) == gold(n+1)),
	("Positive integers n who are part of a Pythagorean triple excluding 0: n^2=a^2+b^2 with integers a,b>0."                          , lambda n: pythagorean(n)),
	("Positive integers n where floor((n!)^(1/n)) is prime"                                                                          , lambda n: prime(floor(fac(n)**(1./n)))),
	("Positive integers n with distance 1 to a perfect square."                                                                      , lambda n: issqr(n-1) or issqr(n+1)),
	("Positive integers n where the number of perfect squares including 0 less than n is prime."                                     , lambda n: prime(numsqr(n))),
	("Prime numbers n where either n-2 or n+2 (exclusive) are prime."                                                                , lambda n: prime(n) and (prime(n-2) ^ prime(n+2))),
	("Positive integers n whose three-dimensional vector's (n, n, n) floored length is prime, floor(sqrt(3*n^2)) is prime."          , lambda n: prime(floor(sqrt(3*n*n)))),
	("Positive integers n who are the sum of a perfect square and a perfect cube (excluding 0)."                                     , lambda n: sumsqrcub(n)),
	
	("Positive integers n whose decimal digit sum is the cube of a prime."                                                           , lambda n: prime(cbrt(decimal_digitsum(n)))),
	("Positive integers n for which decimal_digitsum(n)+n is a perfect square."                                                        , lambda n: issqr(decimal_digitsum(n)+n)),
	("Prime numbers n for which decimal_digitsum(n^4) is prime."                                                                     , lambda n: prime(n) and prime(decimal_digitsum(n**4))),
	("Positive integers n where decimal_digitsum(2*n) is a substring of n."                                                            , lambda n: str(decimal_digitsum(2*n)) in str(n)),
	("Positive integers n whose decimal reverse is prime."                                                                           , lambda n: prime(int(str(n)[::-1]))),
	("Positive integers n who are a decimal substring of n^n."                                                                               , lambda n: str(n) in str(n**n)),
	
	("Positive integers n whose binary expansion has a prime number of 1's."                                                         , lambda n: prime(bin(n).count("1"))),
	("Positive integers n whose 7-segment representation uses a prime number of segments."                                          , lambda n: prime(sevenseg(n))),
	
	# The following three sequences are not interesting enough to be featured.
	#("Positive integers n where the number of unique sums of two positive integers which equal n equals decimal_digitsum(n)."        , lambda n: len(twosum(n)) == decimal_digitsum(n)),
	#("Positive integers n which are not divisible by their decimal digit sum."                                                       , lambda n: n%decimal_digitsum(n) != 0),
	#("Positive integers n whose octal representation is a substring of the octal representation of (n^2)!."                          , lambda n: oct(n)[1:] in oct(fac(n*n))[1:]),
	
()][:-1]

# calculate sequence with given filtering function
def getseq(ftr):
	seq, n = [], 1
	while len(seq) < N:
		if ftr(n): seq.append(n)
		n += 1
	return str(seq)[1:-1]

# print sequences
for s in range(len(sequences)): print "(%02d) %s\n     {%s, ...}\n" % (s+1, sequences[s][0], getseq(sequences[s][1]))
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s