Advertisement
TawratNibir

PoissonC

Jan 28th, 2025 (edited)
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. float poisson(float x, float y)
  5. {
  6.     if (y == 0)
  7.         return exp(-x);
  8.     else
  9.     {
  10.         float res = ((float)x / y) * poisson(x, y - 1);
  11.         printf("P(X = %.0f) = %.12f\n", y, res);
  12.         return res;
  13.     }
  14. }
  15.  
  16. int main()
  17. {
  18.     float x, y;
  19.     printf("Enter the value of lambda and x respectively: \n");
  20.     scanf("%f %f", &x, &y);
  21.     printf("The results for different x are: \n");
  22.     float ans = poisson(x, y);
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement