You are on page 1of 3

n=int(input()) #values

i=0

dq=[i for i in range(1,n+1)] #array to store data

while(len(dq)>1):

dq.pop(0)

dq.append(dq[0])

if len(dq)>1:

dq.pop(0)

i+=1 #no of iteration

print (dq[0],i)

In 50000, top element is 34464.

No of iteration is 49999.
In 9, top element is 2.

No. of iteration is 8.

In 10000, no of cards are 3616.


No of iterations are 9999.

C.

Lowest no of iteration is 2 where I can run to get the same value.

You might also like