about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 440
Copyright Nick Parlante 2017 - privacy