Mantis - Squeak
Viewing Issue Advanced Details
7137 Any feature N/A 07-30-08 11:52 08-17-08 19:05
kwl any  
kwl any  
normal any  
confirmed  
any no change required  
none    
none  
0007137: Highly composite numbers, Integer>>#numberOfDivisorCombinations
Attached is an integer method which computes the number of divisor combinations.

Examples 4096 => 13, 2520 => 48, more and links to background in the attached.
 Integer-numberOfDivisorCombinations-7137-kwl.st [^] (1,127 bytes) 07-31-08 15:35

Notes
(0012420)
nicolas cellier   
07-31-08 08:27   
Ah number theory... could be an add-on package with other functions like totient etc...

I propose that the method would be split in two parts:
- The message #primeFactors certainly is valuable by itself.
- And it could eventually be optimized by other techniques in case of LargeInteger arithmetic (if ever needed).

(0012421)
kwl   
07-31-08 10:00   
Thank you for your interest Nice ;)

But the method does not just compute divisors, it computes all possible combinations of them. And I do not want to split it up, unless there is a demonstratable benefit.

If someone wants to speed it up then computing the next smallest prime factor would benefit performance for sure.

Another optimization would be to not use a dictionary. But this method is for SBE to demonstrate use of Dictionary as Bag.

BTW I doubt you can provide an optimization for Large*Integers :(

And please, do *not* discuss any further here, use private email or squeak-dev as fits, then post *results* to mantis. TIA
(0012422)
kwl   
07-31-08 15:35   
Corrected primesBag inject:into: to primesBag values inject:into: for ANSI compliance.