binary search in python.

Job ID: 35809450

Budget: $30 – $250 USD

I have a function:
def generate_sequence(a, b, y, n, length):
sequence = [a, b]
for i in range(2, length):
next_element = (sequence[i-1] + y) % n
sequence.append(next_element)
return sequence

where:
a is first element of sequence
b is second element of sequence
y is a constant value beetween elements in sequences
n is prime as modulo
length - is a how much elements must be generated.
to generetate samples you should use:
n= 340282366920938463463374607431768211507
a= 143175619015091158262702567736164681468
b= 335999156169938687300833334560756099505
y= 192823537154847529038130766824591418037
length = 30

I want to get binary search algorithm which:
tell me what position in the sequence number c, which is only the upper part of the number being sought, has

example:
elements in sequences:
elem 188540326403847752875589493953579306035 2
elem 41081496637756818450345653346402512565 3
elem 233905033792604347488476420170993930602 4
elem 86446204026513413063232579563817137132 5
elem 279269741181360942101363346388408555169 6
elem 131810911415270007676119505781231761699 7
elem 324634448570117536714250272605823179736 8
elem 177175618804026602289006431998646386266 9
elem 29716789037935667863762591391469592796 10
elem 222540326192783196901893358216061010833 11
elem 75081496426692262476649517608884217363 12
elem 267905033581539791514780284433475635400 13
elem 120446203815448857089536443826298841930 14
elem 313269740970296386127667210650890259967 15
elem 165810911204205451702423370043713466497 16
elem 18352081438114517277179529436536673027 17

we are looking "279269741181360942101363346388408555169" which is number 6 in sequence
and we are looking for high part of" 279269741181360942101363346000000000000" , and it should tell me that is "number six in sequences".

are you able to that?