Degree of two

Report a typo

Your task is to solve the following inequality using a for loop:

2n>=x2^n >= x

The value of x will be given by the input. You need to know the value of n to fulfill two conditions:

  • The inequality is correct;
  • The expression 2n2^n is the minimum possible.

Tip: The loop condition is value < x.

Tip: With each loop iteration, you need to multiply the value variable by two and increase the degree variable by one.

Sample Input 1:

2022

Sample Output 1:

11
Write a program in Go
package main

import "fmt"

func main() {
var x int
fmt.Scan(&x)

degree := 0
value := 1

// Write your loop here

fmt.Println(degree)
}
___

Create a free account to access the full topic