Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Import Libraries
- import numpy as np
- #Declare initial empty arrays
- num = []
- palindromes = []
- #Declare function which will reverse strings
- def reverse(r):
- return int(str(r)[::-1])
- #Generate array of numbers with two three digit factors
- for x in range(100,999):
- for y in range(100,999):
- num.append(x*y)
- #Isolate palindromes
- for x in range(0,len(num)):
- s = (str(num[x]))
- if (num[x]-(reverse(num[x])))==0:
- palindromes.append(num[x])
- #Use NumPy to reorder array in ascending order and print the final value in the array.
- print(np.sort(palindromes)[(len(palindromes)-1)])
Advertisement
Add Comment
Please, Sign In to add comment