@Oberok
5 / 5 / 0
Регистрация: 11.03.2011
Сообщений: 40
|
07.11.2012, 14:09
|
|
Как вариант:
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| #include <iostream>
#include <cmath>
int main()
{
double res = 0;
int factorial(int);
for(int i = 1; i <= 3; ++i)
{
res += factorial(2*i-1) / pow(2,i);
}
std::cout << "Factorial = " << res << std::endl;
system("PAUSE");
return 0;
}
int factorial (int n)
{
if (n==0)
{
return 1;
}
return factorial(n-1)*n;
} |
|
1
|