Talk:Proper divisors: Difference between revisions

Content added Content deleted
No edit summary
Line 22: Line 22:
::: Well... on the one hand, the definition of of what proper divisors are for 1 has changed during this discussion, which makes talking about that a bit odd. On the other hand, the list of factors of zero is probably infinite: 0 = 0*1*2*3*4... Or, put differently: the remainder of dividing zero by 100 is zero. So that can't be adequately represented on a computer, so we probably always treat it as an error case (either that or by never returning from a request for that list of divisors). --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 00:05, 18 December 2014 (UTC)
::: Well... on the one hand, the definition of of what proper divisors are for 1 has changed during this discussion, which makes talking about that a bit odd. On the other hand, the list of factors of zero is probably infinite: 0 = 0*1*2*3*4... Or, put differently: the remainder of dividing zero by 100 is zero. So that can't be adequately represented on a computer, so we probably always treat it as an error case (either that or by never returning from a request for that list of divisors). --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 00:05, 18 December 2014 (UTC)
:::: The task has been changed, so the point of this topic is now settled (for me at least). Re 0, I see the task says "of a positive integer N" so sidesteps the 0 input entirely. Even if we did care, it would for this task be "whatever you've justified divisors(0) returning, without 0 if it was present." That covers divisors returning {}, {0}, {0,1}, error, a lazy list, etc. As an aside, I see sometime between Pari 2.5.3 and 2.6.2 they changed from returning {0,1} to giving a domain error. Sage returns a value error. Wolfram/Alpha indicates "(all non-zero integers are divisors of 0)" [[User:Danaj|Danaj]] ([[User talk:Danaj|talk]]) 01:16, 18 December 2014 (UTC)
:::: The task has been changed, so the point of this topic is now settled (for me at least). Re 0, I see the task says "of a positive integer N" so sidesteps the 0 input entirely. Even if we did care, it would for this task be "whatever you've justified divisors(0) returning, without 0 if it was present." That covers divisors returning {}, {0}, {0,1}, error, a lazy list, etc. As an aside, I see sometime between Pari 2.5.3 and 2.6.2 they changed from returning {0,1} to giving a domain error. Sage returns a value error. Wolfram/Alpha indicates "(all non-zero integers are divisors of 0)" [[User:Danaj|Danaj]] ([[User talk:Danaj|talk]]) 01:16, 18 December 2014 (UTC)
== The two Python Solutions ==
Hi Paddy3118

I believe you when you say the second version is faster than the first, but note (n + 1) // 2 + 1 can be replaced by floor(sqrt(n)) in the first version. 141 rather than 10,000 in the case of 20,000. This would be a fairer comparison!--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 14:32, 19 December 2014 (UTC)