fix bugs

declare j=0 inside first i loop, and set base case to v0=1 not v0=a0