double a;
cin >> a;
double sum=1;
int k=1;
while (sum<=a){
k++;
sum=sum+1/(k*1.0);
}
cout << k << " " << sum;
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
double a;
cin >> a;
double sum=1;
int k=1;
while (sum<=a){
k++;
sum=sum+1/(k*1.0);
}
cout << k << " " << sum;