#include <iostream>
#include <cmath>
using namespace std;
double f(int N, int x) {
if (x == 0)
return sqrt(N);
return sqrt((N - x) + f(N, x - 1));
}
signed main() {
int n;
cin >> n;
cout << f(n, n - 1);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <cmath>
using namespace std;
double f(int N, int x) {
if (x == 0)
return sqrt(N);
return sqrt((N - x) + f(N, x - 1));
}
signed main() {
int n;
cin >> n;
cout << f(n, n - 1);
}