gashink_t

ln(1+x) рекурсией

Feb 11th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. float ln(float X, int N) { //функция вычисления ln(1+x);
  6.     if (fabs(pow(-1, N + 1) * (pow(X, N) / N)) <= 0.001) {
  7.         return 0;
  8.     }
  9.     else {
  10.         return ln(X, N + 1) + pow(-1, N + 1) * (pow(X, N) / N);
  11.     }
  12. }
  13.  
  14. int main()
  15. {
  16.     float x,s;
  17.     printf("vvedite x = ");
  18.     scanf("%f",&x);
  19.     s=ln(x,1);
  20.     printf("ln(1+x) = %f", s);
  21.     return 0;
  22. }
Add Comment
Please, Sign In to add comment