class LoopDetection: def __init__(self,init,f): self.init=init self.f=f self.value=[] self.value_inv={} self.loop_start=-1 self.loop_length=-1 def IteratedComposition(self,n): L=len(self.value) if L<1:self.SetValue(self.init) if nd*d:D+=d+N//d else:D+=d O(LoopDetection(D%B,lambda n:C[n]).IteratedComposition(K-2))