Tuesday, March 5, 2024

22. (a/1!)+(a²/2!)+(a³/3!)+(a⁴/4!)+... :—

22. (a/1!)+(a²/2!)+(a³/3!)+(a⁴/4!)+... :—


#include<stdio.h>

int main()

{

    int i,n,a,f,sum;

    printf("enter value of n and a ");

    scanf("%d%d",&n,&a);

    sum=0,f=1;

    for(i=1;i<=n;i++)

    {

        f=f*i;

        sum=sum+pow(a,i)/(float)f;

    }

    printf("%d",sum);

    return 0;

}


No comments:

Post a Comment