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.
Could someone explain how the above algorithm to calculate A can be used as an alternative to brute force? From what I understand, we don't know the b or the x, so wouldn't we still have a ton of iterations to do regardless? Here's my current approach (brute force):
'''java
for(BigInteger i = ten; i.compareTo(upperLimit) != 1; i = i.add(one))
{
rotated = rotateRight(i);
if(rotated.mod(i).compareTo(zero) == 0)
divisible.add(i);
}
System.out.println(lastFiveDigits(addElements(divisible)));
'''
Edit: Never mind! Not there yet but getting close...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #168: Number Rotations
You are viewing a single comment's thread. Return to all comments →
Could someone explain how the above algorithm to calculate A can be used as an alternative to brute force? From what I understand, we don't know the b or the x, so wouldn't we still have a ton of iterations to do regardless? Here's my current approach (brute force):
'''java
for(BigInteger i = ten; i.compareTo(upperLimit) != 1; i = i.add(one)) { rotated = rotateRight(i); if(rotated.mod(i).compareTo(zero) == 0) divisible.add(i); } System.out.println(lastFiveDigits(addElements(divisible)));
'''
Edit: Never mind! Not there yet but getting close...