Tap here to switch tabs
Problem
Submissions

Problem: Smallest Value After Replacing With Prime Factor Sum

Smallest Value After Replacing With Prime Factor Sum repeatedly replaces a positive integer with its prime-factor sum. Return the smallest value reached, counting repeated prime factors each time.

Statement

You are given a positive integer n.

Repeatedly replace n with the sum of its prime factors. Continue this replacement process until the value of n stops changing.

Return the smallest value that n takes on throughout this process.

Note: If a prime factor divides n multiple times, it must be included in the sum as many times as it divides n.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Value After Replacing With Prime Factor Sum

Smallest Value After Replacing With Prime Factor Sum repeatedly replaces a positive integer with its prime-factor sum. Return the smallest value reached, counting repeated prime factors each time.

Statement

You are given a positive integer n.

Repeatedly replace n with the sum of its prime factors. Continue this replacement process until the value of n stops changing.

Return the smallest value that n takes on throughout this process.

Note: If a prime factor divides n multiple times, it must be included in the sum as many times as it divides n.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5