[Tutor] Fwd: Problem Euler 26
Andre Engels
andreengels at gmail.com
Tue Jul 1 08:12:43 CEST 2008
On Sun, Jun 29, 2008 at 10:34 PM, kinuthiA muchanE <muchanek at gmail.com> wrote:
> Er... er, that does not exactly work as expected but it narrows the
> search to only 3 candidates because of the inclusion of the zero:
>
> (28, '035714286')
> (38, '026315789')
> (81, '012345679')
>
> For 28, the digit, in the fractional part, after 8 is 5, so 5 is
> repeated and as for, 81 the next digit after 7 is 0, so again 0 occurs
> twice. But for 38, the next digit after 9 is 4, and because it has NOT
> occurred before, I assume 38 is the correct answer... and I am wrong!
>
> I suspect I have completely misunderstood the question.
Yes, it seems you have... I will try to rephrase:
For each fraction x/y (y>x to get it below 1), its representation as a
decimal fraction consists of two parts: first some arbitrary series of
numbers, then a series of numbers that is repeated over and over
again. For example, 1/55 = 0.018181818181818..., or in short 0.0(18) -
the arbitrary series here is 0, the repeating part 18. You are asked
to get the largest repeating part.
Your solution finds the longest time before a digit is repeated
instead, which is incorrect because the same digit can be used more
than once in the repeating part (and also because it might occur once
or more in the non-repeating part) - for example, the 1/38 that you
mentioned equals:
0.0(263157894736842105)
A hint for solving this problem: use methods similar to the once you
use for a long division with pen and paper.
--
Andre Engels, andreengels at gmail.com
ICQ: 6260644 -- Skype: a_engels
More information about the Tutor
mailing list