# Issue

I have this model: a simple 8-digit display calculator (no memory buttons, no square root etc etc) has buttons (the decimal point does not count as a 'digit'): 10 buttons for integers 0 to 9, 1 button for dot (decimal point, so it can hold decimals, like from 0.0000001 to 9999999.9), 4 buttons for operations (+, -, /, *), and 1 button for equality (=). (the on/off button doesn't count for this question)

The question is two-fold: how many numbers can they be represented on the calculator's screen? (a math-explained solution would be appreciated)
*AND
if we have to make all 4 basic operations between *any* pair of 2 numbers, of the above calculated, how many operations would that be?

Thank you for your insight and help!

# Solution

For part one of this answer, we want to know **how many numbers can be represented on the calculator's screen.**

Start with a simplified example and work up from there. Let's start with a 1-digit display. With this calculator, you can display the numbers from 0 to 9, and you can display each of those numbers with a decimal point either before the digit (making it a decimal), or after the digit (making it an integer). How many unique numbers can be made?

.0, .1, .2, .3, .4, .5, .6, .7, .8, .9,

~~0.~~, 1., 2., 3., 4., 5., 6., 7., 8., 9.

That's 20 possibilities with 1 repeat number makes 19 unique numbers. Let's find this result again, but using a mathematical approach that we can scale up to a larger number of digits.

Start by finding all the numbers 0 <= n < 1 that can be made. For the numbers to fit in that range, the decimal point must be before the first digit. We're still dealing with 1 digit, so there are 10^{1} different ways to fill the calculator with numbers that are greater than or equal to 0, but less than 1.

Next, find all the numbers 1 <= n < 10 that can be made. To do this, you move the decimal point one place to the right, so now it's after the first digit, and you also can't allow the first digit to be zero (or the number will be less than 1). That leaves you 9 unique numbers.

[0<=n<1] + [1<=n<10] = 10 + 9 = 19

Now we have a scaleable system. Let's do it with 2 digits so you see how it works with multiple digits before we go to 8 digits. With 2 digits, we can represent 0-99, and the decimal point can go in three different places, which means we have three ranges to check: 0<=n<1, 1<=n<10, 10<=n<100. The first set can have zero in its first place, since zero is in the set, but every other set can't have zero in the first place or else the number would be in the set below it. So the first set has 10^{2} possibilities, but each of the other sets has 9 * 10^{1} possibilities. We can generalize this by saying that for any number * d* of digits that our calculator can hold, the set 0<=n<1 will have 10

^{d}possibilities, and each other set will have 9 * 10

^{d-1}possibilities

So for 2 digits:

[0<=n<1] + [1<=n<10] + [10<=n<100] = 100 + 90 + 90 = 280

Now you can see a pattern emerging, which can be generalize to give us the total amount of unique numbers that can be displayed on a calculator with * d* digits:

Unique displayable numbers = 10

^{d}+ d * 9 * 10^{d-1}

You can confirm this math with a simple Python script that manually finds all the unique numbers that can be displayed, prints the quantity it found, then also prints the result of the formula above. It gets bogged down when it gets to higher numbers of digits, but digits 1 through 5 should be enough to show the formula works.

```
for digits in range(1, 6):
print('---%d Digits----' % digits)
numbers = set()
for d in range(digits + 1):
numbers.update(i / 10**d for i in range(10**digits))
print(len(set(numbers)))
print(10**digits + digits * 9 * 10**(digits - 1))
```

And the result:

---1 Digits----

19

19

---2 Digits----

280

280

---3 Digits----

3700

3700

---4 Digits----

46000

46000

---5 Digits----

550000

550000

Which means that **a calculator with an 8 digit display can show 820,000,000 unique numbers.**

For part two of this answer, we want to know **if we have to make all 4 basic operations between any pair of 2 numbers, of the above calculated, how many operations would that be?**

How many pairs of numbers can we make between 820 million unique numbers? 820 million squared. That's 672,400,000,000,000,000 = 672.4 quadrillion. Four different operations can be used on these number pairs, so multiply that by 4 and you get **2,689,600,000,000,000,000 = 2.6896 quintillion different possible operations on a simple 8 digit calculator.**

**EDIT:**

If the intention of the original question was for a decimal point to not be allowed to come before the first digit (a decimal 0<=n<1 would have to start with * 0.*) then the formula for displayable numbers changes to

**10**, which means the amount of

^{d}+ (d - 1) * 9 * 10^{d-1}**unique displayable numbers is 730 million**and the

**total number of operations is 2.1316 quintillion**.

Answered By - schwartz721 Answer Checked By - Senaida (PHPFixing Volunteer)

## 0 Comments:

## Post a Comment

Note: Only a member of this blog may post a comment.