APL/Dev1.1/Dev2809/Progression.c

26 lines
376 B
C
Raw Normal View History

2021-10-05 15:07:50 +02:00
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
int terme;
int resultat;
int nbr1 = 0;
int nbr2 = 1;
printf("Quel terme voulez vous ? :");
scanf("%d",&terme);
for (i = 0; i <terme+1;i++) {
if (i <= 1)
resultat = i;
else
{ resultat = nbr1 + nbr2;
nbr1 = nbr2;
nbr2 = resultat;}
}
printf("%d\n", resultat);
return EXIT_SUCCESS;
}