Advertisement
naeem043

Python Joshepus Problem

Oct 10th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. n = int(input('Enter the number of people: '))
  2. p = 0
  3. for i in range(1,n+1):
  4.     k = pow(2,i)
  5.     if k<= n:
  6.         p += 1  
  7. l = n-pow(2,(p))
  8.          
  9. print("Last survive people: "+str(2*l+1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement