c 语言学习:输出阶乘的算式
代码
c
#include "stdio.h"
int fact(int num){
if (num <= 1){
printf("1 = ");
return 1;
} else {
printf("%d x ",num);
return num * fact(num-1);
}
}
int main(){
int num = 10;
// printf("plz input a number you want to fact: ");
// scanf("%d", &num);
printf("%d\n", fact(num));
}