Skip to content

Instantly share code, notes, and snippets.

@rob-smallshire
Last active May 20, 2016 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob-smallshire/8da49f01170ba0439e7950bf65c670f4 to your computer and use it in GitHub Desktop.
Save rob-smallshire/8da49f01170ba0439e7950bf65c670f4 to your computer and use it in GitHub Desktop.
The longest palindromic primes of n-digits reproducing the first part of an integer sequence seen in a mural at Oslo Gardermoen airport
# The longest palindromic primes of n-digits
# reproducing the first part of an integer
# sequence seen in a mural at Oslo Gardermoen
# airport
from urllib.request import urlopen
def main():
with urlopen('https://oeis.org/A002385/b002385.txt') as response:
encoding = response.info().get_content_charset()
primes = [line.decode(encoding).split()[1] for line in response]
largest_palindromes = {}
for prime in primes:
num_digits = len(prime)
largest_palindromes[num_digits] = int(prime)
print(largest_palindromes)
if __name__ == '__main__':
main()
@rob-smallshire
Copy link
Author

{1: 7, 2: 11, 3: 929, 5: 98689, 7: 9989899, 9: 999727999, 11: 99999199999}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment