This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP1/E4.c

15 lines
331 B
C
Raw Normal View History

2016-01-17 19:32:46 +01:00
/* Calcule la somme des N premiers termes de la série harmonique */
2016-01-17 18:39:09 +01:00
#include <stdio.h>
#include <math.h>
int main() {
double n, s = 0, k;
printf("Saisissez N\n");
scanf("%lf", &n);
for (k = 1; k <= n; k++) {
2016-01-17 19:32:46 +01:00
s += 1/k; // Si k avait été un entier, 1/k aurait été un entier aussi (0)
2016-01-17 18:39:09 +01:00
}
printf("%lf\n", s);
return 0;
}