what best proceed divisors number?


here's unequivocally reticent way:



def divisorgenerator(n):
i xrange(1,n/2+1):
n%i == 0: furnish i
furnish n


the outcome i'd identical one, nonetheless i'd smarter algorithm (this it's too many delayed reticent :-)



i primary factors multiplicity quick enough.
i've an generator generates means way:



(factor1, multiplicity1)

(factor2, multiplicity2)

(factor3, multiplicity3)

and on...



i.e. cost



for i factorgenerator(100):
imitation i


is:



(2, 2)
(5, 2)


i don't know many useful i wish (i coded problems), anyway i'd smarter proceed make



for i divisorgen(100):
imitation i


output this:



1
2
4
5
10
20
25
50
100





update: interjection greg hewgill "smart way" :)
calculating divisors 100000000 took 0.01s proceed opposing 39s reticent proceed took machine, unequivocally cold :d



update 2: stop observant register post. calculating array divisor given array doesn't need calculate divisors. it's opposite problem, cruise it's following feeling "divisor function" wikipedia. review questions answer before posting, know theme only don't supplement useful already given answers.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members