# Modulo Arithmetic hidden property (a mod n+ 1)

I was solving a programming question where we need to find compact form of a number and finding difficult to understand hidden modulo property behind it . I searched a lot but could not figure out.

Compact Form of a given number n is computed as follows:

-Step 0. Repeat step 1 and step 2 until a one digit number is reached.

Step 1. Divide the digits in the number into pairs of adjacent digits. If at any time, the number of digits in n are odd (except when the number of digits is 1), we add a zero on left side of the number.

Step 2. Take the (sum modulo 7) + 1 of the numbers in each pair and get the new number made of these digits.

Example

• Pairs of digits in 123456 are (12)(34)(56).
• New number formed by sum modulo 7 + 1 is ( (1+2)%7 + 1 ) ( (3+4)%7 + 1 ) ( (5+6)%7 + 1 ) = 415.
• Since there are odd number of digits in the new number, we add 0 to its left and make new pairs as (04)(15).

• New number formed by (sum modulo 7 + 1) is (4%7 +1)(6%7 + 1) = 57. Pair of digits in 57 is (57). New number formed by sum modulo 7 + 1 is ( 12%7 + 1 ) = 6." Since 6 is a one digit number, it is already in compact form.

My doubt is when three digits are left like 415 and if we take its any permutation like 514 and then take 0514 and apply the same procedure, ans comes out to be same. Like (05%7 +1)((1+4)%7 +1)= 66 => (6+6) %7 +1 =6. Similar result comes when we take any other permutation like 154 etc.

This happens with any number a and and I think for any mod m.

Which property of mod is being hidden behind this?