Number can be very big.Script is taking number as a number list and crossing from 10-decimal based system to n-based system until list equals 5.I don't use letters like in 16-base system(hex).Example if result will be AB5 in hex list will be [10,11,5]. Some ideas how to optimize or/and change this to recursion?Any other hints/ideas for optimizing this code?r=-1number = [9,7,1,3,3,6,4,6,5,8,5,3,1]l=len(number)p=11while (number[-1]!=5): i=1 while(i<=l):  #for x in reversed(xrange(1,i)):  for x in xrange(i-1,0,-1):   number[x]+=(number[x-1]*r)   while(number[x]<0):    number[x]+=p    number[x-1]-=1    if number[0]==0:     #number.pop(0)     del number[0]     i-=1     l-=1  i+=1#print p p+=2 r=-2print p-2Algorithm in theory:From start we have some decimal number: 2507 . Base of decimal as everyone know is 10. list=[2, 5, 0, 7]  :    [2, 5, 0, 7]         # 2507 decimal(base 10)        1.        l[1]=l[1]+(diff_between_earlier_and_current_base*l[1-1]        2.        1.l[2]=l[2]+(diff_between_earlier_and_current_base*l[2-1]        1.l[1]=l[1]+(diff_between_earlier_and_current_base*l[1-1]        3.        1.l[3]=l[3]+(diff_between_earlier_and_current_base*l[3-1]        1.l[2]=l[2]+(diff_between_earlier_and_current_base*l[2-1]        1.l[1]=l[1]+(diff_between_earlier_and_current_base*l[1-1]if some element (while doing this) will be  <0 we need to borrow from l[curent-1] until element<0    (if we doing subtraction below the line we are borrowing 10 but when we converting to 11 base we are borrowing 11 so when we have [2,-2] >> [1,9])    Result in 11 base:    [1, 9, 7, 10]I think any way to optimize this is to write my code as recurrent function but i don't know how to do this.Anyone?
Any way to change optimize this or/and change to recursion?
python;optimization