반응형
#include<stdio.h>
long long factorial(int);
int main(void){
for(int i = 1; i <= 10; ++i){
printf("%d! = %lld\n", i, factorial(i));
}
return 0;
}
long long factorial(int x){
long long int result = 1;
for(int i = 1; i <= x; ++i)
result *= i;
return result;
}
반응형
'C' 카테고리의 다른 글
[C언어] 실습: Baseball Game 프로그램 구현하기 (0) | 2021.07.15 |
---|---|
[C언어] rand() (0) | 2021.07.13 |
[C언어] 배열(Array)과 포인터(Pointer) 2 (0) | 2021.07.05 |
[C언어] 버블 정렬 (Bubble Sort) (0) | 2021.07.01 |
[C언어] 선택 정렬 (Selection Sort) (0) | 2021.06.30 |