home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * CH06_07.C RΘcurrence des fonctions *
- *********************************************************************/
-
- #include<stdio.h>
-
- int LitInt( void);
- unsigned long int SommeSerie( int);
-
- main( void)
- {
-
- int n;
-
- printf(" *** Calcul de la somme des n premiers entiers ***\n");
-
- do
- {
- printf("\n Entrez n: ");
- n= LitInt();
- }
- while( n<= 0);
-
- printf(" La somme des termes: S( %d)= %lu",
- n, SommeSerie( n));
- }
-
- unsigned long int SommeSerie( int p)
- {
- if( p<= 0)
- return 0; /* c'est aussi la condition d'arrΩt. */
- else
- return( p+ Somme_Serie( p- 1));
- }
-
- int LitInt( void)
- {
- int Entier;
- while( scanf("%d", &Entier)!= 1)
- while( getchar() != '\n');
- while( getchar() != '\n');
- return ( Entier);
- }
-