Versions 1 through n were released in order. At some point a bad version was shipped, and every version after it is also bad.
You can test whether a version is bad. Find the first bad one using as few tests as possible.
Implement firstBadVersion(n, firstBad), where firstBad is the answer the testing API would reveal - treat version v as bad exactly when v >= firstBad. Return the first bad version.