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]
integern
Constraints: 2 ≤ n ≤ 10000.
[output]
an integer
Puzzles
Similar Kata:
Stats:
Created | Feb 10, 2017 |
Published | Feb 10, 2017 |
Warriors Trained | 905 |
Total Skips | 32 |
Total Code Submissions | 1201 |
Total Times Completed | 403 |
JavaScript Completions | 134 |
C# Completions | 43 |
Python Completions | 230 |
Ruby Completions | 31 |
Total Stars | 18 |
% of votes with a positive feedback rating | 94% of 124 |
Total "Very Satisfied" Votes | 111 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |