wrong output

hi Im making a program that will answer the
equation F = 1/(n+1)! + 2/(n+2)! + 3/(n+3)!...... n/(n+n)!

#include<iostream>
using namespace std;
int main(){
int b,a,x,i,c,,n;
float y,sum;

cin>>i;

a=1;
n=i;
sum=0;
for(c=1;c<=i;c++){

b=n+c;



for(x=1;x<=b;x++){


a=a*x;

}
y=c/a;
sum=sum+y;
}


cout<<y;
return 0;
}

it always answer 0....
a>c (because a=(c+i)!), so c/a<1, but since a and c are integers, integer arithmetic is applied, and the result is truncated to zero.
Topic archived. No new replies allowed.