Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //найти сумму членов ряда 1 + 1/2 + 1/3 +...+ 1/n
- #include <iostream>
- using namespace std;
- int sum(double n);
- int main()
- {
- double a;
- cout << "Enter number: " << endl;
- cin >> a;
- cout << sum(a) << endl;
- system("pause");
- return 0;
- }
- int sum(double n)
- {
- double f = 0;
- if (n == 1){
- f = 1;
- }
- else{
- f = 1 / n + sum(n - 1);
- }
- return f;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement