a=1b=77x=1y=14lister,ans,a=[],[],a%b*10whileanotinlister:lister.append(a)# 1. not includes x of x.123456ans.append(a//b)a=(a%b)*10nolooplen=lister.index(a)# when the iteration appears in anslooplen=len(ans)-nolooplen# how many after iterationprint(lister,ans,nolooplen,looplen)code=''foriinrange(x-1,y):# 2. minus 1 from (x, y+1)ifiinrange(len(ans)):code+=str(ans[i])else:code+=str(ans[(i-nolooplen)%looplen])# (remove first)%loop length+firstprint(code)
近期评论