Hello all,

Today there was a contest held at my university, which featured 5 problems for a 3h contest.

My team performed poorly, especially because I’m not very used to “work under pressure” and I lack time to study some more theory behind some problems after contests are over… I’m slowly trying to change that and I will try to use some problems of this contest towards the goal of improving my abilities.

The problem was just this:

Given two positive numbers a and b, such that:

0 < a, b <= 191244368

We were asked to calculate the length of the cycle of the fraction a/b, where cycle is defined as a chain of repeated digits on the decimal expansion of the fraction.

For example, if a= 1 and b = 7, answer is 6, because:

1/7 = 0.142857 142857 …

where 142857 repeats for ever.

Any hints or ideas people can give me will be very helpful to me

Thank you in advance,

Bruno

PS: I believe it might be somehow related to prime numbers, but, I’m really clueless…