0

I made some simple mistake (conversion?) in my program.. I will be gratefull if anyone has an idea what's wrong with it;) The problem is not with the algorithm itself so I am not explaining it - the problem is: why the condition placed in the code between // HERE and // HERE seems to be never true? (The function does not work correctly) Try this piece of code with 0.7 and 4 on entry.

```
int s(int k) // factorial for integers
{
if (k==0 || k==1) {return 1;}
else {return (s(k-1))*k;}
}
double newtonsymbol(double r, int k)
{
if (k<0) return 0;
int s(int k); //that's factorial above
static double t=r;
double h;
h=r+k-1.0;
static double numerator=r;
double denominator;
std::cout<<h-t<<" "<<t<<std::endl;
/* that's optional; it shows the mistake; the condition would be fulfilled if h-t==0 */
//HERE
if (t==h)
//HERE
{denominator=s(k); std::cout<<"ok"<<std::endl;
return (numerator/denominator);}
if (h<-10) {return 3;}
// that is added to stop the function so you can see what's going on
{std::cout<<"not ok"<<std::endl;
numerator=r*newtonsymbol(r-1,k));}
}
int main ()
{
double p=0.7; int l=4;
std::cout<<newtonsymbol(p,l);
system("pause");
return 0;
}
```