Skip to main content

Timeline for Largest prime factor function

Current License: CC BY-SA 4.0

5 events
when toggle format what by license comment
Oct 10, 2018 at 22:13 comment added Joop Eggen @aventurin the return did not take into account the remaining factor n. And indeed (c+2)² = c²+4c+4 so starting with int cSquare = 3*3; and at every step adding (c + 1) << 2. Thanks.
Oct 10, 2018 at 22:05 history edited Joop Eggen CC BY-SA 4.0
added 47 characters in body
Oct 10, 2018 at 21:27 comment added aventurin Your largestPrimeFactor(6) returns 2 instead of 3. Calculating c * c on every loop iteration could be avoided if you adjust the upper limit accordingly. This could also speed up the special case where n is the square of a prime.
Oct 10, 2018 at 13:09 history edited Joop Eggen CC BY-SA 4.0
added 54 characters in body
Oct 10, 2018 at 13:04 history answered Joop Eggen CC BY-SA 4.0