Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
yellow-dog47384285dWhat have you tried so far?
4160Tuesdays114285dI need help in this?
razorraz1285d@tekashi I have tried this
def divisers (n)
from math import sqrt
max_n = int(sqrt(n) + 1)
divs = [(I, n / I) for I in xrange(2, max_n) if n % i ==0]
if len(divs) ==0;
return %d is prime % n
return sorted(set(div for div_pair in divs in div_pair]))
inaba5077284dRust isn't functional right? So by the sound of it you're about to split a number into it's prime factors.
Basically what you wanna do is take the number, ckeck if you can divide it by two, then ever time you can you add 2 to the result array and then divide the number by 2. Then when you can't divide by 2 any more you (make a new loop where you) check if you can divide by three (then 5, 7, 9, all of the uneven numbers until the iterating number is less than the number you're checking), where you check for division by three (then 5, 7, etc) and if that is possible you divide the number by three and add three to the result array.
Or if you want to cheat and look at code https://github.com/inabahare/...
SomeNone869284dThis is devRant, not devHelp… that said, please search for Euler problem 3, it is very similar, and a solution to that is quite trivial to modify so it does what you want. Solutions in all sorts of languages can be easily found.