再求f(x,n)

w6826301 / 2023-08-02 / 原文

#include<iostream>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;
double a(double n,double x){
    if(n==0){ 
        return 1;//结尾条件 
    }else{
        return x/(n+a(n-1,x));//表达式 
    } 
}
int main(){
    double x,n,y;
    cin>>x>>n;
    y=a(n,x);
    cout<<fixed<<setprecision(2)<<y;
    return 0;
}