Guess Number Higher or Lower II

You are playing a guessing game with the following rules:

  • I pick a number between 1 and n.
  • You guess a number. If you guess correctly, you win and pay $0.
  • If you guess wrong, you pay the dollar amount equal to your guess, and I tell you whether the actual number is higher or lower.
  • You continue guessing until you get the right number.

Given n, return the minimum amount of money you need to guarantee a win.

Examples
Input: 10
Output: 16
Hints

Guess Number Higher or Lower II

You are playing a guessing game with the following rules: