본문 바로가기

IT/Algorithm

Algorithm: 계승(Factorial)

#include <stdio.h>


int fatorial(int num);


void main(){

int num;

int ftr;


scanf("%d",&num);

ftr = fatorial(num);

printf("%d\n",ftr);

}


int fatorial(int num){

if(num == 0){

return 1;

}else

return num * fatorial(num-1);

}