Advertisement
GIEA

L4.28

Mar 26th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int S, X, contador, fatorial=1, multiplicador=1;
  7.     printf("Digite o valor de X: ");
  8.     scanf("%d",&X);
  9.     S=X;
  10.     for(contador=1;contador>=1;contador++)
  11.     {
  12.         if(multiplicador==19)
  13.         {
  14.             fatorial*=multiplicador;
  15.             S-=X/fatorial;
  16.             printf("S = %d",S);
  17.             return 0;
  18.         }
  19.         fatorial*=multiplicador;
  20.         if(contador%2!=0)
  21.         {
  22.             S-=X/fatorial;
  23.             multiplicador++;
  24.         }
  25.         else
  26.         {
  27.             S+=X/fatorial;
  28.             multiplicador++;
  29.         }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement