[sbe-discussion] Re: Using Dictionary as Bag, small example related to Ramanujan's highly composite numbers

stephane ducasse stephane.ducasse at free.fr
Fri Aug 1 09:05:55 MEST 2008


Great!

Stef

On Jul 31, 2008, at 8:07 AM, Klaus D. Witzel wrote:

> On Wed, 30 Jul 2008 22:41:49 +0200, stephane ducasse wrote:
>
>> Some texts :)?
>
> The following example employs a Dictionary as a Bag for computing the
> number of all *combinations* of *divisors* which divide an integer  
> without
> remainer. The Dictionary's keys are the prime divisors and its  
> values are
> the number of occurences found during the loop. When a new prime  
> divisor
> is found, message #at:ifAbsent: initializes its value in the Bag to  
> zero.
> Then message #at:put: increments the occurences in the Bag.  
> Eventually the
> Bag's values are used in an #inject:into: message for computing *d*  
> the
> number of all possible combinations. Note that this is Ramanujan's  
> highly
> composite number *n* when the *d* is greater than for any smaller *n*.
>
>> Stef
>> On Jul 30, 2008, at 2:36 PM, Klaus D. Witzel wrote:
>>
>>> Hi,
>>>
>>> I've made a small example on how to use a Dictionary as Bag, for
>>> computing
>>> all divisior combinations of an integer. The background is from
>>> Ramanujan's highly composite numbers; two related links are included
>>> in
>>> the method comments, FWIW, another link (with refs) is
>>>
>>> - http://mathworld.wolfram.com/HighlyCompositeNumber.html
>>>
>>> The example source code is downloadable from
>>>
>>> - http://bugs.squeak.org/view.php?id=7137
>>>
>>> Perhaps it fits between [Collection Iterators] and [Some Hints for
>>> using
>>> Collections]. The method features #at:put: #at:ifAbsent: and
>>> #inject:into:
>>> on a Dictionary used as Bag (and of course #gcd: ).
>>>
>>> Something else you need from me?
>>>
>>> Cheers,
>>> Klaus
>>> _______________________________________________
>>> Sbe-discussion mailing list
>>> Sbe-discussion at iam.unibe.ch
>>> https://www.iam.unibe.ch/mailman/listinfo/sbe-discussion
>>>
>>
>> _______________________________________________
>> Sbe-discussion mailing list
>> Sbe-discussion at iam.unibe.ch
>> https://www.iam.unibe.ch/mailman/listinfo/sbe-discussion
>
>
> _______________________________________________
> Sbe-discussion mailing list
> Sbe-discussion at iam.unibe.ch
> https://www.iam.unibe.ch/mailman/listinfo/sbe-discussion
>



More information about the Sbe-discussion mailing list