title: How to find the largest power of two
body: <p>I am trying to create a program to find the largest power of two less than or equal to a given number.</p>
  
  <p>Given below is the code I have made for it:</p>
  
  <pre><code>boundary = int(input("Enter your number: "))
  x = boundary
  ctr = 0                           
  if x % 2 == 0:                      
      while x &gt;= 0:
          x /= 2
          ctr += 1
  else:
      ctr = 0
      while x &gt;= 1:
          x /= 2
          ctr += 1
      ctr -= 1
  </code></pre>
  
  <p>It seems to work only with odd numbers (the else statement part) and does not output anything when an even number is entered.
  I'd like to know what I'm doing wrong here.</p>