Hello, please help, I have a variable number. Example “5,544,332” I must go through it from right to left, multiplying each digit by the numbers that make up the numerical series 2, 3, 4, 5, 6, and 7. Some idea?

Hi,

Can you share expected output?

Regards,

Hi,

If you want to calculate checkdigit modulas 11 / weight 2,3,4,5,6,7 ,the following sample will help you

```
strNum = "5,544,332"
strNum = CInt(Double.Parse(strNum,System.Globalization.NumberStyles.Any)).ToString
```

then

```
arrResult = strNum.Reverse().Select(Function(c,i) CInt(c.toString)*(2+(i mod 6))).ToArray
```

check digit will be

```
11-(arrResult.Sum() mod 11)
```

Sample

Sample20240223-1.zip (4.1 KB)

Regards,

To process the number “5,544,332” from right to left, multiplying each digit by the numbers in the series 2, 3, 4, 5, 6, and 7, you can follow these steps:

*Remove commas**: Replace commas to have a clean number.

2.*Reverse the number**: Convert the number to a string, reverse it for right-to-left processing.

3.*Multiply each digit**: Loop through each digit, multiply it by the corresponding number in the series, and sum the results.

4.*Repeat the series**: If the number has more digits than the series, start the series again from the beginning.

Here’s a short outline of the code that could be used within an `Invoke Code`

activity in UiPath:

Dim numberString As String = “5,544,332”.Replace(“,”, “”)

Dim series As Integer() = {2, 3, 4, 5, 6, 7}

Dim reversedNumber As Char() = numberString.Reverse().ToArray()

Dim result As Integer = 0

Dim seriesIndex As Integer = 0

For Each digitChar As Char In reversedNumber

Dim digit As Integer = Integer.Parse(digitChar.ToString())

result += digit * series(seriesIndex)

seriesIndex = (seriesIndex + 1) Mod series.Length

Next

The `result`

variable will hold the final sum after multiplication. You can then use this result as needed in your workflow.

@JulioCesar1988 Try this in your Studio.

```
Assign activity:
NumberString = "5,544,332"
Assign activity:
CleanedNumber = NumberString.Replace(",", "").Replace(" ", "")
Assign activity:
DigitsArray = CleanedNumber.ToCharArray.Select(Function(c) CInt(c.ToString)).ToArray
Assign activity:
NumericalSeries = {2, 3, 4, 5, 6, 7}
Assign activity:
Result = 0
For Each activity (TypeArgument: Int32, Values: DigitsArray.Reverse):
Assign activity within For Each:
Result = Result + item * NumericalSeries(index % NumericalSeries.Length)
Message Box (to display the result):
Result.ToString
```

This workflow takes the input number, cleans it, processes each digit according to the specified numerical series, and displays the result. Adapt the workflow based on your specific needs.

Try this way:

```
Assign-> number = "5,544,332"
Assign-> multipliers = {2, 3, 4, 5, 6, 7}
Assign-> result = String.Join(vbCrLf,number.Replace(",", "").
Reverse().
Select(Function(digit, index) Convert.ToInt32(digit.ToString()) * multipliers(index Mod multipliers.Length)).
ToList())
```

`number`

is of DataType System.String. `multipliers`

is of DataType Array(System.Int32). `result`

is of DataType System.String.

Or

```
Assign-> number = "5,544,332"
Assign-> multipliers = {2, 3, 4, 5, 6, 7}
Assign-> result = String.Join(vbcrlf,Enumerable.Range(0, number.Replace(",", "").Reverse().ToArray().Length).
Select(Function(i) $"{number.Replace(",", "").Reverse().ToArray()(i)} * {multipliers(i Mod multipliers.Length)} = {Convert.ToInt32(number.Replace(",", "").Reverse().ToArray()(i).ToString()) * multipliers(i Mod multipliers.Length)}").
ToList())
```

Both the queries should work

Regards