+ 21
[🏆 CHALLENGE 🏆] REPEATING DIGITS 🔢1⃣2⃣
Challenge #5 Let's do some math this time. The challenge is to make a code which outputs the number whoose 1/n will have the maximum no of repeating decimals till the number inputted. Eg. Input->10 Output-> 7, It has 6 repeating digits. 1/7=0.(142857) Note : 1/7 =0.142857142857... so, 142857 repeats, which has 6 digits so the output is 6. 1/7 has move no of repeating decimals than any 1/n when n is less than 10. EDIT: DON'T TRUST FLOAT CALCULATIONS. Good luck 👍 Happy coding. At least try to participate.
11 odpowiedzi
+ 4
it turns out that the highest period until a give point is always a prime less than n with a period length of p-1.for more information see this link https://oeis.org/A051626
https://code.sololearn.com/cX2Fa4zwiE60/?ref=app
+ 22
i also think that there is some need to restrict the domain
//will see this later now👋👋
+ 18
+ 14
see
1/1=1(no repeat)
1/2=0.5(no repeat)
1/3=0.33333(1 digit repeating)
1/4=0.25
1/5=0.2
1/6=0.166666(1 digit)
1/7=0.142857142857142857(6 digits )
1/8=0.125
1/9=0.1111(1 digit)
1/10=0.1
So, 1/7 has the most no of repeating digits. So the answer is 7.
+ 13
Here's again 😁
Made in accordance with Swapnil's suggestions. It was much harder than I expected 😓
Thanks for the great challenge 😉
https://code.sololearn.com/c4DS7g9HjMGq/?ref=app
+ 5
Cool, may try if I have time. (1/97, anyone?)
+ 5
oh! my god!!
thats some challenge!!!
+ 4
@Swapnil Srivastava Do I correctly understand that I have for the input 10 to check every previous division so
k ele [1....10] = 1/k
1/1, 1/2, 1/3, .... 1/10? right? So the next question is how to proceed with periodic values because obviously they would have the most repeating digits if not defined otherwise (max-length/2 - 1). Or are they excluded by definition of your challenge :). So we have to restrict the example a little bit.
+ 3
Assumed that periodic is not allowed. By my definition if a value occurs more than once behind each other in the accordance => skip. Here my solution written in Java:
https://code.sololearn.com/cySky6n3EB9n/#java
--------------
Ad: I decide to write a second version which also finds multiple maxes:
https://code.sololearn.com/cWcXtaa1GHbw/#java
+ 2
This is my try, sorry for delay.
It was hard but teached me a lot about accuracy of divisions in python, thanks @Swapnil Srivastava for the challenge.
Anyway my solution isn't short but is complete and it calculate every periodic part of every razional number, simple or mixed.
https://code.sololearn.com/c5KYOua25Jdx/#py
+ 1
It will calculate only from 1 to 42
Because there are many loop and long data type limitations.
But very right answer )))
https://code.sololearn.com/c1l9DXK5Obi0/?ref=app