# float numbers

I want to find a float number between 2 to 1000 which has the longest set of different digits after the dot. The set has not to repeat. What do I do so that set will be printed because of the limits according types.

10/27/2021 2:36:27 PM

TeaserCode8 Answers

New AnswerTeaserCode Here you can increase the amount of digits displayed by cout... #include <iostream> #include <iomanip> <-- needed using namespace std; int main() { cout<<setprecision(15); <-- needed double myVariable = 0; int n = 2; while (n <= 1000) { cout << 1.0/n++<<endl; } return 0; } You can read about it here and in the c++ documentation http://faculty.cs.niu.edu/~hutchins/csci241/output.htm

And which number can be an example for having such longest set of different digits? What did you mean by "The set has not to repeat" when you already said "longest set of *different* digits" Also what did you mean by "the limits according types"?

1/2= 0.5 1/3= 0.(3) 1/4= 0.25 1/5= 0.2 1/6= 0.1(6) 1/7= 0.(142857) 1/8= 0.125 1/9= 0.(1) 1/10= 0.1 Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.

In the case 1/7, it has the longest decimal part with different digits. I would like to declare such float variable, which will display as long as possible. I try with string but it goes only to ten digits.