A possible Calculus question involving classifying numbers according to their digits

573 Views Asked by At

Background

Hi, I'm a programmer and I'm annoyed about a number problem that I don't know how to work.

I don't have a mathematical background. This isn't for school or for work. Just something I think about often when I program.

Goal

I would like to be able to work through problems like this on my own without having to spend hours tallying it on paper. But I don't know how to even search for help on google as I lack all terminology to describe the problem or mathematical field.

Problem

I have a set s{x} of base 10 numbers between 0 and some large number, Y.

Each number in s{x} is stored in a folder according to what digit it has in the ones, tens, hundreds, and thousands's place.

Specifically: ones/tens/hundreds/thousands/x.txt

An example: x = 1,305,491 would be stored in the following location: 1/9/4/5/1305491.txt

The last folder on the file path is known as the terminal folder. In the above example its 5.

Question 1

How many numbers would be in each terminal folder after all numbers in |s{x}| are classified?

Attempts

So enumerating out the folder possibilities we get: ten_possible_folders/ten_possible_folders/ten_possible_folders/ten_possible_folders.

So that would be 10^3 possibilities.

I can see on paper if I tally all numbers less than 1 thousand that each terminal folder would have log(log(log(log(x)))) numbers. So each terminal folder would have one number in it.

I intuitively feel that if I were given 10 thousand numbers that each terminal folder would have ten numbers in it.

So the number of numbers in each terminal folder would be simply 10* the number of digits in Y.

Is this correct?

Question 2

The next thing I'm curious about is how to talk about what I'm asking about.

What field of mathematics studies this? It has to deal with rate of growth, so is it calculus?

2

There are 2 best solutions below

0
On BEST ANSWER

Your text $n$ files will be basically evenly distributed within your $10^4$ terminal folders (not $10^3$ as you state). Therefore, the average number of files in each terminal folder would be $n/10^4$.

0
On

Um, you have the $1000$ folders and $Y + 1$ files. The folders are filed systematically one folder at a time.

So each folder has $\frac {Y+1}{10000}$ files. Round up for the first folders that have one extra and round down for the later folders that haven't had the final file put it.

That's all there is to it.

If you want more details or rigor and a thorough answer:

Let $Y = 10000k + w$ where $0 \le w < 10000$ (that's the remainder formula).

Let the folders be $/a/b/c/d$ and let $M = 1000 a + 100b + 10c + d$. If $M > w$ then folder $/a/b/c/d$ will have $k$ files. If $M \le w$ then the folder $/a/b/c/d$ will have $k + 1$ files.

i.e. The foldeer $/a/b/c/d$ will have the files $M, 10000 + M, 20000 + M, 30000 + M, ..... , 10000(k-1) + M$ and it will have file $10000k + M$ if and only if $10000k + M \le 10000k + w = Y$. So that is either $k$ files if $M > w$ or $k +1$ if $M \le w$.

......

What field of mathematics studies this? It has to deal with rate of growth, so is it calculus?

No. It has to do with dividing numbers evenly into equal parts. So it's division in basic arithmetic.