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

 

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

Write a method that returns the sum of all of the prime factors of the integer input parameter n (n>=2). If n is a prime number, return n. For example, primeSum(12) returns 7 because the prime factors of 12 are 2, 2, 3 and 2+2+3=7. This method only needs one loop and no recursion, or you can try to solve it recursively with no loops.


primeSum(87) → 32
primeSum(172) → 47
primeSum(7) → 7

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

public int primeSum(int n) { }

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: 440

Copyright Nick Parlante 2017 - privacy