c++ how to expess a mathematical term
<p>i have the following :
<img src="http://i.stack.imgur.com/IVCEc.png" alt="enter image description here"></p>

<p>I only want (for now) to express the (s 1) , (s 2) term .
For example ,(s 1)=s  , (s 2)= s(s-1)/2! , (s 3)=s(s-1)(s-2)/3!.</p>

<p>I created a factorial function :</p>

<pre><code>//compute factorial
int fact(int x){

if (x==0)
return 1;
else
    return fact(x-1)*x;

}
</code></pre>

<p>and i have problem in how to do right the above.</p>

<pre><code>.....
double s=(z-x[1])/h;
double s_term=0;
    for (int p=1;p&lt;=n;p++){
        if p==1 
            s_term=s;
            else
                    s_term=s*(s-p)/fact(p+1);

    }
</code></pre>

<p>Also, it is that : s=(x - x0)/h.
I don't know if i have declared right the s above.(i use x<a href="http://i.stack.imgur.com/IVCEc.png" rel="nofollow">1</a> in the declaration because this is my starting point)</p>

<p>Thank you!</p>
