```
class Solution(object):
def firstBadVersion(self, n):
"""
:type n: int
:rtype: int
"""
def binS(start, end):
mid = (start+end)/2
if(isBadVersion(mid)):
if(not(isBadVersion(mid-1)) or mid==1):
return mid
elif(isBadVersion(mid-1)):
end = mid-1
return binS(start,end)
elif(not(isBadVersion(mid))):
start = mid+1
return binS(start,end)
return binS(0,n)
```