SHARE
TWEET

program_euler.c

takai Oct 12th, 2017 (edited) 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. //funcao fatorial
  4.  
  5. double fatorial(int n){
  6.  
  7.     int j;
  8.     double f=1.0;
  9.  
  10.     for (j=1; j <= n; j++){
  11.  
  12.         f = f * j;
  13.  
  14.     }
  15.  
  16.     return f;
  17.  
  18. }
  19.  
  20. //programa para calcular numero de euler usanto a funcao fatorial
  21.  
  22. void main (){
  23.  
  24.     double e;
  25.     int i;
  26.  
  27.     for (i=1; 1.0/fatorial(i) < 0.000001; i++){
  28.  
  29.         e = e + 1.0/fatorial(i);
  30.     }
  31.  
  32.     printf ("Valor aproximado do Numero de Euler:%f \n", e);
  33.  
  34.     system ("PAUSE");
  35.  
  36. }
RAW Paste Data
Top