```
public class Solution extends VersionControl {
public int firstBadVersion(int n) {
if(n==1) return n;
return firstHelper(1,n);
}
public int firstHelper(int start, int end){
if(start==end) return start;
int mid=start+ (end-start)/2;
if(isBadVersion(mid) && !isBadVersion(mid-1)) return mid;
if(isBadVersion(mid) && isBadVersion(mid-1)) return firstHelper(start, mid-1);
return firstHelper(mid+1, end);
}
}
```