Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- //fonction de factorielle en notion de recursivité
- double factorielle(int a){
- if (!a || a == 1) {
- /*
- !a <=> a == 0
- */
- return 1;
- }else{
- return a*factorielle(a-1);
- }
- }
- int main(){
- // declaration
- int a;
- printf("Donner la valeur a caculer: ");
- // la valeur doit etre >=0
- do {
- scanf("%d",&a);
- } while (a<0);
- printf("factorielle de %d est: %0.f\n",a,factorielle(a));
- //%0.f <=> 0 nbr apré la vergule.
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement