Skip to content

Practice Smallest Value After Replacing With Sum of Prime Factors

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2507
LeetCode Problem

Smallest Value After Replacing With Sum of Prime Factors

Problem Statement

Repeatedly replace n by the sum of its prime factors counted with multiplicity. Return the smallest value reached during this process, including the initial value.

Source: Smallest Value After Replacing With Sum of Prime Factors on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 15
Output
5

# Example 2

Input
n = 3
Output
3

Constraints

2 <= n <= 10^5

Related LeetCode Problems

Practice more problems similar to Smallest Value After Replacing With Sum of Prime Factors.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.