Ad
  • Custom User Avatar

    How long does your program run for 1992104689? How long does it run for 1999999817?

  • Custom User Avatar

    First of all, be careful when disclosing your solution or approach in the discourse. Even if it doesn't work, you risk spoiling the fun for others who are trying to discover methods of their own.

    Secondly, inputs go up to 2^31 as stated in the description. Iterating over that range is bound to fail, as worst case complexity is O(n) (the number may be prime).
    Dealing with primes generally requires a slightly more sophisticated approach. I recommend just doing some research; a good starting point is here.