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

27th Oct 2021, 2:36 PM
TeaserCode
+ 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
27th Oct 2021, 6:10 PM + 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"?
27th Oct 2021, 2:44 PM
Ipang
+ 2
And the digits in the fractional part are expected to be unique?
27th Oct 2021, 2:52 PM
Ipang
+ 2
Mr Paul very good and useful ans. Thank you very much.
27th Oct 2021, 6:46 PM
TeaserCode
+ 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.
27th Oct 2021, 2:48 PM
TeaserCode
+ 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.
27th Oct 2021, 3:01 PM
TeaserCode
+ 1
Can you use a double? Or long double?
27th Oct 2021, 4:39 PM 