프로그래밍 알고리즘

[정올 1309] 팩토리얼

꾸준한사람 2023. 1. 3. 04:48
반응형

http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=589&sca=99&sfl=wr_hit&stx=1309 

 

JUNGOL

 

www.jungol.co.kr

#include <stdio.h>

typedef unsigned long long u64;
int N;
u64 ans = 1;

int main() {
	scanf("%d", &N);
	while (N) {
		if (N == 1) printf("1! = 1\n");
		else printf("%d! = %d * %d!\n", N, N, N - 1);
		ans *= N--;
	}
	printf("%lld\n", ans);
	return 0;
}
반응형