Advertisement
ppupil2

exp_tuananh

Mar 8th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <conio.h>
  5.  
  6. double giaithua(int x) {
  7.     double P = 1;
  8.     for (int i = 1; i <= x; i++) {
  9.         P = P*i;
  10.     }
  11.     return(P);
  12. }
  13.  
  14. double myExp(double x, int n) {
  15.     double S, h;
  16.     S = 1;
  17.     for (int i = 1; i<=n; i++) {
  18.         h = pow(x,i) / giaithua(i);
  19.         S = S + h;
  20.     }
  21.     return(S);
  22. }
  23.  
  24. int main() {
  25.     double a;
  26.     a = myExp(1.5, 1000);
  27.     printf("%lf\n", a);
  28.    
  29.    
  30.    
  31.  
  32.     return(0);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement