Shouldn’t the value of y and z be same here:-
x=10**17+4
v=10**9+7
y=((x*(x+1))%v)*pow(2,v-2,v)
print(y%v)
z=int(x/2)*(x+1)
z=z%v
print(z)
Shouldn’t the value of y and z be same here:-
x=10**17+4
v=10**9+7
y=((x*(x+1))%v)*pow(2,v-2,v)
print(y%v)
z=int(x/2)*(x+1)
z=z%v
print(z)
int(x/2)!=x//2
X is even so it is equal
Ohh but it is showing unequal. And X//2
Gives y and z to be same. Thanx
x/2
has a liitle bit of error and int(x)
is just floor(x)
. So if instead of 5 it is 4.9999999 you will get 4.