1

First than nothing, sorry for my english, I'm not native.

I was wondering how I could represent mathematically, each digit of a number.

Example: 172

X = 172.

How can I represent each digit of the number x, algebraically?

Another example: n=420 so n1+n2+n3 => 6

How is the summation, or the multiplication of each of the digits, mathematically represented?

Thanks, and sorry for my english.

  • 2
    I am not too sure I understand. How about $100n_1+10n_2+n_3?$ – For the love of maths Jan 21 '19 at 14:27
  • 4
    It's not very clear what you mean. But I can start: The last digit (the 'ones') can be extracted by taking the number in modulus 10. The second-to last digit can be extracted by dividing the number by 10, then taking the floor function of the result, and again taking modulo 10. You can continue this process on and on ... – Matti P. Jan 21 '19 at 14:27
  • You may code the decimal representation of a number $n$ of four digits as $a_3 a_2 a_1 a_0$ wher the index $i$ is the power of $10^i$. – Mauro ALLEGRANZA Jan 21 '19 at 14:29
  • Thus : $172 = 1 \times 10^2 + 7 \times 10^1 + 2 \times 10^0$. – Mauro ALLEGRANZA Jan 21 '19 at 14:35

2 Answers2

1

If you have a number $a$ with digits $d_n...d_1d_0$ in a system with radix $b$, then your can write it as: $a = \sum_{i=0}^{n}{b^id_i}$. This is often used in programming in order to extract a digit through division and remainder (modulo) operations. In your case I assume that your number is in decimal $b=10$, then it can be written as: $172 = 1\times 10^2 + 7\times 10^1 + 2\times 10^0 = 100 + 70 + 2$. For your second example: $420 = 4\times 10^2 + 2\times 10^1 + 0\times 10^0 = 400 + 20 + 0$.

lightxbulb
  • 2,047
  • Sorry, I'll try to explain a little more. In programming, for example, an string n = "1234"; n[0] means 1, n[1] means 2, etc... what I would like to know, it's how could I represent each digit but mathematically. assuming that x > 9. If x it's a number with two or more digits, how could I representate that? – Georgia Fernández Jan 21 '19 at 20:50
  • In my example $d_n = n[0], d_{n-1} = n[1], …, d_0 = n[n]$. Note that I couldn't use another variable since you named your array $n$ for some reason which was the count $-1$ of digits in my example. – lightxbulb Jan 21 '19 at 21:06
0

I do not think there is a standard convention for this that everyone uses. Instead, you have a choice among several different conventions you could follow.

First there is the choice of how to represent each digit by itself. A number is not the same thing as a string, even when we talk about the digits of its base-ten representation. Even in a computer, depending on which system you are using you might find the smallest-value bits are in the lowest-numbered bytes, or you might find they are in the highest-numbered bytes.

Mathematically, it's usually preferable to number the digits whichever way makes it easier to do whatever you need to do with them. Sometimes people find it convenient to say that the "$0$th" digit is the one in the units/ones place, the $1$st digit is in the tens place, and so forth; then then can say that the place value of the digit in the $k$th place is $10^k,$ so if the digit in that place is $d_k$ then its total contribution to the number's value is $d_k \times 10^k.$ But you can just as easily say the first digit is the one on the left and the last digit is the one on the right, as long as you don't find that this becomes confusing later.

Next there is how you put the digits together. Everyone will understand what you mean if you write something like $$n_1 \times 10^2 + n_2 \times 10^1 + n_3 \times 10^0 \text{ where } 0 \leq n_k \leq 9$$ or $$d_2 \times 10^2 + d_1 \times 10^1 + d_0 \times 10^0 \text{ where } 0 \leq d_k \leq 9.$$

It is then easy to represent sums and products of digits, for example $$ \sum_{k = 1}^3 n_k = n_1 + n_2 + n_3 $$ and $$ \prod_{k = 0}^2 d_k = d_2 \times d_1 \times d_0. $$

You can write the notation $n_1 \times 10^2 + n_2 \times 10^1 + n_3\times 10^0$ a little more compactly as $\sum_{k = 1}^3 n_k 10^{3-k}.$ You may judge whether this notation is helpful or confusing.

If you must write representations of the digits of many numbers you might consider just placing the symbols for each digit in a row the way we write a number with known digits. If you do this, however, you should explain what you mean by the notation before you use it. For example, you might say:

The number $n_1 \times 10^{k-1} + n_2 \times 10^{k-2} + \cdots + n_k \times 10^0$ will be written $n_1n_2\ldots n_k.$

This will help to explain to readers that when you write $n_1n_2n_3$ you mean a three-digit number, not three numbers that are multiplied together. Of course then if you do want to multiply the digits you will have to use some kind of explicit multiplication operator such as $\times$ or use the $\prod$ notation. So the three-digit number $n_1n_2n_3$ has sum $n_1+n_2+n_3$ and product $n_1\times n_2\times n_3$.

There are other things people sometimes find convenient to do such as defining a function $d(n)$ that gives the number of digits in the base-ten representation of $n,$ so that one can write $$ n = n_1n_2\ldots n_{d(n)},$$ with sum of digits $$ \sum_{k = 1}^{d(n)} n_k = n_1 + n_2 + \cdots + n_{d(n)} $$ and product $$ \prod_{k = 1}^{d(n)} n_k = n_1 \times n_2 \times \cdots \times n_{d(n)}. $$

It's all a matter of what you need. But in any case it's a good policy to explain how you are representing the digits of numbers rather than just using a notation and expecting the reader to figure it out.

David K
  • 98,388