ramontricolor12

LISTA 02 - exercício 52

May 27th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int valor, fat, i, j;
  6.     float resultado = 0;
  7.  
  8.     printf("\nInforme um valor de 1 a 5: ");
  9.     scanf("%d", &valor);
  10.  
  11.     for(i = 0; i <= valor; i++)
  12.     {
  13.         fat = i;
  14.  
  15.         if(fat < 2)
  16.             fat = 1;
  17.         else
  18.         {
  19.             for(j = i; j > 1; j--)
  20.             {
  21.                 fat = fat * (j-1);
  22.             }
  23.         }
  24.         resultado = resultado + (1.0 / fat);
  25.     }
  26.     printf("\nRESULTADO: %f \n", resultado);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment