Search All of the Math Forum:

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

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

 Messages: [ Previous | Next ]
 Bill Rowe Posts: 1,647 Registered: 3/14/08
Re: Integer Length Count
Posted: Nov 24, 2012 2:43 AM

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}}

Date Subject Author
11/24/12 Ulrich Arndt
11/24/12 James Stein
11/24/12 Bob Hanlon
11/24/12 Bill Rowe