-
- #pragma hdrstop
-
- #pragma argsused
-
- #include <conio.h>
- #include <iomanip.h>
- #include <iostream.h>
-
- int factorielle(int n) ;
-
- void main(void)
- {
- int rep ;
- int nombre ;
-
- cout << "entrez un nombre : " ;
- cin >> nombre ;
-
- rep = factorielle(nombre) ;
-
- cout << endl << "la factorielle de " << nombre << " est : " << rep ;
-
- cout << endl << endl << "appuyer sur une touche pour terminer..." ;
- getch() ;
- }
- //---------------------------------------------------------------------------
-
-
- int factorielle(int n)
- {
- // pour 0 -> rep = 1
- if (n == 0)
- return 1 ;
-
- // 5! = 5 * 4!
- return n * factorielle(n-1) ;
- }
#pragma hdrstop
#pragma argsused
#include <conio.h>
#include <iomanip.h>
#include <iostream.h>
int factorielle(int n) ;
void main(void)
{
int rep ;
int nombre ;
cout << "entrez un nombre : " ;
cin >> nombre ;
rep = factorielle(nombre) ;
cout << endl << "la factorielle de " << nombre << " est : " << rep ;
cout << endl << endl << "appuyer sur une touche pour terminer..." ;
getch() ;
}
//---------------------------------------------------------------------------
int factorielle(int n)
{
// pour 0 -> rep = 1
if (n == 0)
return 1 ;
// 5! = 5 * 4!
return n * factorielle(n-1) ;
}