Find the smallest positive integer n, such that 1 / n and 1 / (n + 1) is less than the difference 0.0000001. And output n 1 / n, 1 / (n + 1), 8 bits are decimal.
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
int n=1;
double x;
do
{
n++;
x=1.0/n-1.0/(n+1);
}
while(x>=0.0000001);
cout<<fixed<<setprecision(8);
cout<<n<<"\n"<<1.0/n<<"\n"<<1.0/(n+1);
}