Calcule les termes de la suite de Robinson jusqu’à obtenir une boucle.
Essayez robinson(“0”) ou robinson(“40”).
def robinson(string): print(0,string) count=0 sequence=[string] while True: string="".join("%d%d"%(string.count(str(digit)),digit) for digit in range(9,-1,-1) if string.count(str(digit))) if string in sequence: print("Repetition of %s at #%d"%(string,sequence.index(string))) break count+=1 sequence+=[string] print("%d %s"%(count,string))