#includeint factorial(int n) { int res, i; res = 1; for(i = 2; i <= n; i++) { res *= i; } return res; } int factorial2(int n) { if (n == 1) return 1; return n * factorial2(n - 1); } int main(void) { printf("Hello World\n"); printf("%d\n", factorial(5)); printf("%d\n", factorial2(5)); return 0; }
댓글 없음:
댓글 쓰기