알고리즘/정올

1309. 팩토리얼

혬혬 2020. 12. 10. 16:44
728x90

 

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std; 

void factoral(int n, long long answer) {
	if (n == 0) {
		cout << n + 1 << "! = " << n + 1 << endl;
		cout << answer << endl;
		return;
	}
	cout << n + 1 << "! = " << n + 1 << " * " << n << "!" << endl;
	factoral(n - 1, answer * n);
}
int main() {

	long long n = 0;
	cin >> n;
	factoral(n - 1, n);


	return 0;
}

 

www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=589&sca=2080

 

JUNGOL

 

www.jungol.co.kr

 

728x90