We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is by far the hardest problem of any rep unit ones. The key thing is the information that a is multiple of 10. This means we must find up to 45 primes whose multiplicative order is of type 2^x * 5^y where x <= 9 and y <= 9. There is no need to calculate a^b as in case of Java can be extremely long taking into account large input values. While looping thru the list of primes we can't have any expensive operations, only simple modulo. I also handled special case where a has factor of prime > 334973.
Hint: Max factor prime of rep unit we are interested in is: 670001
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #132: Large repunit factors
You are viewing a single comment's thread. Return to all comments →
This is by far the hardest problem of any rep unit ones. The key thing is the information that a is multiple of 10. This means we must find up to 45 primes whose multiplicative order is of type 2^x * 5^y where x <= 9 and y <= 9. There is no need to calculate a^b as in case of Java can be extremely long taking into account large input values. While looping thru the list of primes we can't have any expensive operations, only simple modulo. I also handled special case where a has factor of prime > 334973.
Hint: Max factor prime of rep unit we are interested in is: 670001