Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
442 B
152
Indexable
Never
#include<iostream> 
#include<iomanip>  

using namespace std;  

double sum4(double n){ 
	double sum = 0; 

	for(int i = 1; i <= n; i++){ 
		sum += i;
	}  
	if(n == 0) return 0;
	return (1/sum)+ sum4(n-1);
}

int main(){ 
	double n, arr[100]; 
	cin >> n;  
	for(int i = 1; i <= n; i++){ 
		cin >> arr[i];
	} 
	for(int i = 1; i <= n; i++){ 
		cout << setprecision(8) << fixed << sum4(arr[i]) << endl;
	}
	
return 0;
}