Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- float poisson(float x, float y)
- {
- if (y == 0)
- return exp(-x);
- else
- {
- float res = ((float)x / y) * poisson(x, y - 1);
- printf("P(X = %.0f) = %.12f\n", y, res);
- return res;
- }
- }
- int main()
- {
- float x, y;
- printf("Enter the value of lambda and x respectively: \n");
- scanf("%f %f", &x, &y);
- printf("The results for different x are: \n");
- float ans = poisson(x, y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement