Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int factorial(int n)
- {
- if (n<=1)
- {
- return 1;
- }
- else
- {
- return n*factorial(n-1);
- }
- }
- int main()
- {
- setlocale(0, "rus");
- double e;
- cout << "Введите e: ";
- cin >> e;
- double sum = 0;
- double temp;
- int i = 1;
- while ( (temp = 1.0/factorial(2*i)) >= e )
- {
- sum += temp;
- i++;
- }
- cout << sum << endl;
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment