Search
⌘K

Leetcode 2507. Smallest Value After Replacing With Sum of Prime Factors

Repeatedly replace n with the sum of its prime factors (counting multiplicity) until it no longer changes, and return the smallest value reached. The core challenge is performing efficient repeated prime factorization / detecting when a fixed point (e.g., a prime or 4) is reached for n up to 10^5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.