Today's objective is to write a function that takes in a number and returns the sum of all its prime factors. For example, if 10 were passed in then the function would return 7 (2 + 5 = 7). The number 1 is not considered prime.
Today's objective is to write a function that takes in a number and returns the sum of all its prime factors. For example, if 10 were passed in then the function would return 7 (2 + 5 = 7). The number 1 is not considered prime.
Permalink: http://problemotd.com/problem/prime-summation/
Content curated by @MaxBurstein
Comments:
Karl - 10 years, 6 months ago
Do you mean 210?
3 and 7 aren't factors of 10 :P
reply permalink
Max Burstein - 10 years, 6 months ago
Whoops I messed up on that one. I updated the problem
reply permalink
David - 10 years, 6 months ago
I looked at the problem just in time to see your edits. Lucky me. _^
reply permalink
Anonymous - 10 years, 6 months ago
reply permalink
Max Burstein - 10 years, 6 months ago
Could always change prime_factors to a set to speed up look up time. Other then that it looks good. I like it.
reply permalink
Alex - 10 years, 6 months ago
reply permalink
Mre64 - 10 years, 6 months ago
perfectly simple, love it...
reply permalink
bumbleguppy - 10 years, 6 months ago
javascript
reply permalink