Comments

I have used the fact that a number n for its every multiple adds (n-1) numbers to the tally of numbers not divisible by that number n. For example :- 3*1 = 3 leaves (3-1) = 2 numbers which are not divisible by 3 which are 1,2. 3*2 = 6 adds another two numbers to the list of not divisibility which are 4,5. total list becomes (1,2,4,5) i.e. 4 numbers. this is because a number will have n-1 numbers between its two multiples which are not divisible by that number and will have remainder 1 to n-1.

d=k//(n-1)  # finding how many multiples of n-1 is that number
r=k%(n-1)   # this is the remainder which will be added as an offset
if(r==0):   # if r=0 i.e. n-1 divides k then it means the required number 1 less 
    r=-1    # therefore r=-1
ans=(n*d) + r # this is the ans which depicts how many multiples of n has been used in k and + remainder to get the extra number

Hi, I have solved the ques in O(1) time without binary search. You can see here 79680203