You are viewing a single comment's thread. Return to all comments →
Java was used to create a working solution that ran in under 2 seconds for the worst case scenarion (20 testcases with N having a maximum value of 100 million in all of these cases and each test result was computed independently -- so no time savings because the testcase was the same in all of these instances)
The challenging part of this solution was efficently computing the primes up to 50 million (maximum N divided by smallest prime) and saving them in an array. This is done once. This array is then referenced in all of the test cases to produce the results desired.