The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Integer Length Count
Replies: 4   Last Post: Nov 24, 2012 2:43 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James Stein

Posts: 130
Registered: 5/8/10
Re: Integer Length Count
Posted: Nov 24, 2012 2:41 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I think this meets your problem description:

Tally [ integerList // IntegerLength ]


f [ n_ ] := Module [ {maxInt, nInts, list },
maxInt = 1000000000;
nInts = n;
list = RandomInteger [ { 0, maxInt }, nInts ] ;
Tally [ list // IntegerLength ] // Sort // AbsoluteTiming
] ;

The good news: f [ one hundred million ] runs in under 7 seconds (on
my computer).
The bad news: f [ one billion ] hangs (or runs inordinately long ).


On Fri, Nov 23, 2012 at 12:28 AM, <> wrote:
> I use a function in SAS that takes, in my case, a billion different integ=

ers of varying length and counts the frequency of the length of each intege=
r by converting the digits in the integers into alpha characters and counti=
ng the frequency of the right most position of the alpha character.
> I am trying to do more and more routine programming in Mathematica and af=

ter poking around in documentation for the past 4 hours have yet to find th=
e parallel function in Mathematica for counting the integer frequency lengt=
h in a big data set. My family wants me to drop everything and put the Turk=
ey in the oven. My cat Sylvester even fell asleep on his back in front of t=
he refrigerator with his little legs up in the air, so he want miss the tra=
nsfer of the Turkey from the stove to the refrigerator. OH WELL -- IT'S SHO=
> Meanwhile, let me know any recommendations you have on a Mathematica func=

tion that parallels the SAS Function.
> Sylvia Hobbs

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.