Solving palindromic 'Triangle Quest' puzzle in Python
I ended up doing the following (thanks @raina77ow for the idea):
for i in range(1, N+1):
print((111111111//(10**(9-i)))**2)
for i in range(1,int(input())+1):
print(int((10**i-1)/9)**2)
1 -> ( 10 - 1) / 9 = 1, 1 * 1 = 1
2 -> ( 100 - 1) / 9 = 11, 11 * 11 = 121
3 -> ( 1000 - 1) / 9 = 111, 111 * 111 = 12321
4 -> (10000 - 1) / 9 = 1111, 1111 * 1111 = 1234321