Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
Bill Rowe

Posts: 1,647
Registered: 3/14/08
Re: Integer Length Count
Posted: Nov 24, 2012 2:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 11/23/12 at 3:28 AM, sylviehobbs@comcast.net wrote:

>I use a function in SAS that takes, in my case, a billion different
>integers of varying length and counts the frequency of the length of
>each integer by converting the digits in the integers into alpha
>characters and counting the frequency of the right most position of
>the alpha character.


>Meanwhile, let me know any recommendations you have on a Mathematica
>function that parallels the SAS Function.


To count the number of digits in an integer (base 10)

In[3]:= a = Table[RandomInteger[10^n], {n, 5}]

Out[3]= {2,22,96,7194,38207}

In[4]:= Length[IntegerDigits@#] & /@ a

Out[4]= {1,2,2,4,5}

To get the frequency of any list of items

In[5]:= Tally[RandomInteger[10, 10000]]

Out[5]= {{7, 966}, {1, 920}, {3, 918}, {9, 937}, {0, 864}, {5, 918},
{6, 910}, {10, 890}, {4, 892}, {8, 924}, {2, 861}}





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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.