Skip to main content

Timeline for Prime factors of a number in C

Current License: CC BY-SA 3.0

4 events
when toggle format what by license comment
Feb 20, 2015 at 1:57 comment added user65308 Your suggestion has helped me. The runtime has come down from nearly an hour to 2-3 seconds. Thank you.
Feb 19, 2015 at 17:26 comment added Sparky @ManishKasireddy: I don't think that you need to explicitly check if 'x' is prime. If 'x' is not prime, then its factors have already been eliminated from 'n' and the modulus test in the subsequent while-loop will be non-zero on the 1st try. If 'x' is prime, then the while-loop modulus test will only succeed if it is a factor of 'n'. If you keep the for-loop in there, you are going to be doing K (where K >= 1) modulus tests to pointlessly test if it is prime or not.
Feb 19, 2015 at 16:26 comment added user65308 If I remove the for-loop, how can I determine if x is prime?
Feb 18, 2015 at 19:48 history answered Sparky CC BY-SA 3.0