@edkallenn/

somatorio_diferente-stack.c

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>

float soma(int n);

int main(){
  int i;
  printf("#n\tsoma(n)\n");
  printf("===================\n");
  for(i=1;i<=20;i++){
    printf("%d\t%f\n", i, soma(i));
  }
  //getchar();
}

float soma(int n){
  if(n==1)
    return 0.5;
  else
    return soma(n-1) + (n/(1.0+n));
}