Dear All,
I am trying to generate a sequence like the one below:
f3=1!+0!
f4=2!+1!
f5=3!+2!
by definition 0!=1
Below is my code for this problem, I am getting an error - passing arg 1 of fact makes pointer from integer without a cast
Code:
#include<stdio.h>
int fact(int a[]);
int main()
{
int n,*a,i;
scanf("%d",&n);
for(i=3;i<=n;i++)
{
a[1]=a[2]=1;
a[i]= fact(a[i-1])+ fact(a[i-2]);
printf("\t %d",a[i]);
}
system("pause");
return 0;
}
int fact(int a[])
{
int i,factorial=1;
for (i=1;i<=a[];i++)
{
factorial*=i;
}
return factorial;
}
Kindly help me out in debugging this error, I have tried changing int a[] to *a but to no avail. Thank you for your help.