6 kyu

Simple Fun #115: Factor Sum

230 of 403myjinxin2015

Description:

Task

Consider the following operation:

We take a positive integer n and replace it with the sum of its prime factors (if a prime number is presented multiple times in the factorization of n, then it's counted the same number of times in the sum).

This operation is applied sequentially first to the given number, then to the first result, then to the second result and so on.., until the result remains the same.

Given number n, find the final result of the operation.

Example

For n = 24, the output should be 5.

24 -> (2 + 2 + 2 + 3) = 9 -> (3 + 3) = 6 -> (2 + 3) = 5 -> 5. So the answer for n = 24 is 5.

Input/Output

  • [input] integer n

Constraints: 2 ≤ n ≤ 10000.

  • [output] an integer
Puzzles

Stats:

CreatedFeb 10, 2017
PublishedFeb 10, 2017
Warriors Trained905
Total Skips32
Total Code Submissions1201
Total Times Completed403
JavaScript Completions134
C# Completions43
Python Completions230
Ruby Completions31
Total Stars18
% of votes with a positive feedback rating94% of 124
Total "Very Satisfied" Votes111
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes1
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • raulbc777 Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad