http://en.wikipedia.org/wiki/Binomial_theorem
here a link about the theorem
but i only need to the the (a+b)^n
where a=1 and n is a integer and 0<b<1
here's my code.can't seem to execute properly.no programming error.i think so la
posted at edu essential.but i don't think they can help
#include <stdio.h>
#include <math.h>
double facto (double fac);
double kire_2(int a,double b,int n);
double kire_2(int a,double b,int n)
{
double sum1=0,sum2=0,count=0,temp_m=1,temp_n;
for(temp_n=1;count>=0;count++)
{
sum1+=temp_m*pow(a,n-count)*pow(b,count);
temp_m*=(n-count)/facto(count+1);
if(n-count==count)
return sum1+sum2;
sum2+=temp_n*pow(a,count)*pow(b,n-count);
temp_n*(n-count)/facto(count+1);
}
}
double facto (double fac)
{
double bogey;
if(fac==0)
return 1;
for(bogey=1;fac>=2;fac--)
bogey*=fac;
return bogey;
}
int main()
{
int n,a=1;
double b;
printf("Enter b and n\n");
scanf("%lf %d",&b,&n);
printf("(%d+%.2lf)^%d",kire_2(a,b,n));
scanf("lf",&n);
return 0;
}
the error:entered b and n but the program just exit and didn't show anything
me:using bloodshed c++
hope u all can help me
Jan 25 2006, 10:07 PM, updated 20y ago
Quote
0.0138sec
0.35
5 queries
GZIP Disabled