Find a set of four consecutive six digit numbers which satisfies the following:
- The last four digits of the first (smallest) number form a palindrome.
- The last five digits of the second number form a palindrome.
- The second through fifth digits of the third number form a palindrome.
- The fourth (largest) number is a palindrome.
198888 198889 198890 198891
199999 200000 200001 200002
for n in range(100000, 999997):
first = str(n)
second = str(n+1)
third = str(n+2)
fourth = str(n+3)
if first[2]==first[5] and first[3]==first[4]:
if second[1]==second[5] and second[2]==second[4]:
if third[1]==third[4] and third[2]==third[3]:
if fourth[0]==fourth[5] and fourth[1]==fourth[4] and fourth[2]==fourth[3]:
print(n,n+1,n+2,n+3)
|
Posted by Larry
on 2023-02-28 08:39:35 |