int j;
for( j=0;j<=i;j++)
{ v.push_back(val);
val= val*(i-j)/j+1;
}
return v;
In the line val=val*(i-j)/j+1 ; the error is occuring.
Just change your code to this-
int j;
for( j=0;j<=i;j++){
v.push_back(val);
val= val*(i-j)/(j+1);
}
return v;
This error was occurring because you were dividing the value with j
in line 4 that was initially 0
, however you were adding one but you should have used ()
.