Last active
May 20, 2016 12:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{1: 7, 2: 11, 3: 929, 5: 98689, 7: 9989899, 9: 999727999, 11: 99999199999}