#10872
#include <iostream>
using namespace std;
int fac(int n)
{
if (n <= 1)
return 1;
return n = n * fac(n - 1);
}
int main()
{
int N;
cin >> N;
cout << fac(N);
return 0;
}
#10870
#include <iostream>
using namespace std;
int fib(int n)
{
if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n - 2) + fib(n - 1);
}
int main()
{
int N;
cin >> N;
cout << fib(N);
return 0;
}
#2447
#include <iostream>
using namespace std;
void star(int i, int j, int n)
{
if ((i % 3) == 1 && (j % 3) == 1)
{
cout << " ";
}
else if (n == 0) //n이 3의 제곱근이므로 3으로 나눠질때만 *찍기
{
cout << "*";
}
else
{
star(i / 3, j / 3, n/3);
}
}
int main()
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
star(i, j, N);
cout << "\n";
}
return 0;
}
#11729
#include <iostream>
#include <cmath>
using namespace std;
void hanoi(int n, int A, int B, int C)
{
if (n == 1)
{
cout << A << " " << C << "\n";
}
else
{
hanoi(n - 1, A, C, B);
cout << A << " " << C << "\n";
hanoi(n - 1, B, A, C);
}
}
int main()
{
int N;
cin >> N;
cout << (int)pow(2, N) -1 << "\n";
hanoi(N, 1, 2, 3);
}