[Codewars] Which x for that sum?

Which x for that sum?

  • Time :
  • Space :
1
2
3
4
5
6
7
#include <bits/stdc++.h>
using namespace std;

double solve(double m)
{
return (2 * m + 1 - sqrt(4 * m + 1)) / 2 / m;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2023/05/09/PS/Codewars/which-x-for-that-sum/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.