id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > mar11_2016_BONUS_sumFactorsPrime
prev  |  next  |  chance

Write a method that recursively determines the "ultimate" sum of the prime factors of 'num'. What makes it "ultimate" is that you do not stop until the answer itself is a prime number. For example, if 'num' is 16, the sum of the prime factors of 16 is 8 (2+2+2+2), but 8 is NOT prime, so now you need to find the sum of the prime factors of 8, which is 6 (2+2+2). But 6 is not prime, so you need to find the sum of the prime factors of 6, which is 5 (2+3). Since 5 is a prime number you are done! so the result for 16 is 5. Look at the test data for further examples.


mar11_2016_BONUS_sumFactorsPrime(4165) → 7
mar11_2016_BONUS_sumFactorsPrime(595) → 29
mar11_2016_BONUS_sumFactorsPrime(273) → 23

...Save, Compile, Run (ctrl-enter)

public int mar11_2016_BONUS_sumFactorsPrime(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy