+ 2

# 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.

8 Answers

+ 3

TeaserCode
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

+ 2

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"?

+ 2

And the digits in the fractional part are expected to be unique?

+ 2

Mr Paul very good and useful ans. Thank you very much.

+ 1

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.

+ 1

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.

+ 1

Can you use a double? Or long double?

+ 1

I do that but it display only six digits. I need more of them at least fifteen.

Hot today