int Tn(int n)
{
...//返回数列第n项值
}
int InnerGetMaxN(int threshold, int sum, int n)
{
int newSum = sum + Tn(n+1);
return newSum >= threshold ? n : InnerGetMaxN(threshold, newSum, n + 1);
}
int GetMaxN(int threshold)
{
return InnerGetMaxN(threshold, 0, 0);
}
void main()
{
cout << GetMaxN(1000);
}