Very_Slow_code

This program is running horribly slow. Pls tell me where is the issue in this code:-

v=10**9+7
fac={0:1,1:1}
inv={0:v,1:1}
f,j=1,1
for i in range(2,500):
	f=f*i
	
	x=v//i
	y=v-x*i
	j=-(x)*inv[y]*j

	if f>v:
		f=f%v
	if j>v:
		j=j%v
	fac[i]=f
	inv[i]=j