MatveyL

for igor

Nov 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. def uberi(s):
  2. lol = ""
  3. for i in range(len(s)-2):
  4. if i <= (len(s)-2)//2:
  5. lol+='1'
  6. else:
  7. lol+='0'
  8.  
  9. return lol
  10.  
  11.  
  12.  
  13.  
  14.  
  15. a = int(input())
  16. ans = ""
  17. s = ""
  18. check = 0
  19. bina = str(bin(a))
  20.  
  21.  
  22.  
  23. for i in range(len(bina) - 2):
  24. s += bina[2+i]
  25.  
  26.  
  27.  
  28. if(len(s) % 2 == 0):
  29. kek = len(s) // 2
  30. tr = len(s) -1
  31. else:
  32. kek = len(s) // 2 + 1
  33. tr = len(s)
  34.  
  35. for i in range(tr):
  36. if i <= tr // 2:
  37. ans+='1'
  38. else:
  39. ans+='0'
  40.  
  41.  
  42.  
  43.  
  44. for i in range(kek):
  45. if a % int(ans,2) == 0 and check == 0:
  46. check = 1
  47. print(int(ans,2))
  48.  
  49. else:
  50. if check == 0:
  51. ans = uberi(ans)
Add Comment
Please, Sign In to add comment