Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- float SUMM(float n) {
- //float sum = 0;
- if (n == 0)
- return 1;
- if (n > 1.0) {
- return 1.0 + SUMM(1.0 / n);
- n--;
- }
- }
- int main() {
- setlocale(LC_ALL, "russian");
- float sum = 0;
- float n;
- cout << "Enter n: ";
- cin >> n;
- for (float i = 1; i <= n; i++) {
- sum = sum + float(1 / i);
- }
- cout << "Sum = " << SUMM(n) << endl;
- cout << "Sum = " << sum << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement