참조:#include< stdio.h>
#include< stdlib.h입니다>
//반복
unsigned long fact (unsigned short value) {
int res = 1;
for(int i = 1; i <= value; i++) {
res *= i;
}
return res;
}
//재귀적
unsigned long fact_recursive (unsigned short number)
{
if (number == 0)
return 1;
else
반환 번호 * fact_recursive(숫자 - 1);
}
int main()
{
int 숫자;
printf("숫자 입력: ");
scanf("%d",& 숫자);
printf("%d의 계승: %d\n",number,fact);
0을 반환합니다.
}
Please disable your ad blocker and refresh the window to use this website.