Retired

Sum of Prime Factors (retired)

Description:

Prime Factorization

nZ2\forall n \in \Z_{\ge2}, there exists an unqiue prime factorization such that:

n = (p1^k1)(p2^k2)(p3^k3)...

Prime Factorization in Wiki

Task

Given a positive integer n, create a function, perform the following procedure:

Factor n into its prime factors and calculate the sum of these factors.

Take the resulting sum and factor it into its prime factors, then compute the sum again.

Repeat this process until the result is a single prime number.

Example

sum_of_prime_factors(30) : (2)(3)(5) -> sum_of_prime_factors(2+3+5) : (2)(5) -> sum_of_prime_factors(2+5) : 7
#  should return 7

sum_of_prime_factors(18) : (2)(3^2) -> sum_of_prime_factors(2+3) : 5 #  The powers of prime numbers should be ignored.
#  should return 5

sum_of_prime_factors(314159) : 314159
#  should return 314159

Input/Output

  • Type of input : int

  • Range : 2n1072 \le n \le 10^7

Mathematics

More By Author:

Check out these other kata created by SmallWolfxDDD

Stats:

CreatedAug 18, 2024
Warriors Trained16
Total Skips0
Total Code Submissions21
Total Times Completed12
Python Completions12
Total Stars0
% of votes with a positive feedback rating42% of 6
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes1
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • SmallWolfxDDD Avatar
Ad