798129 divided by 40 
The aim is to understand the frequency of 40 in 798129.

On to step 1:
The number 40 fits into 7 0 times, leaving a remainder of 7.
The number 0 becomes the next digit in our result. 
Result so far: 0.0
Subtract 0 from 7 to get 7.
Bring next digit (9) of the dividend behind the 7 and repeat the process: 79 / 40

Going ahead to step 2:
40 goes into 79 1 times with a remainder of 39.
Put 1 as the next digit of the answer. 
Result so far: 1.0
The remainder is 39 after subtracting 40 from 79.
Bring next digit (8) of the dividend behind the 39 and repeat the process: 398 / 40

Advancing to step 3:
40 can be fit into 398 9 times, resulting in a remainder of 38.
Use 9 as the next digit of our solution. 
Result so far: 19.0
The remainder is 38 after subtracting 360 from 398.
Append the next digit (1) from the dividend to 38 and continue with: 381 / 40

On to step 4:
381 divided by 40 is 9 with a remainder of 21.
Put 9 as the next digit of the answer. 
Result so far: 199.0
If we take 360 away from 381, we end up with 21.
Append the next digit (2) from the dividend to 21 and continue with: 212 / 40

On to step 5:
40 can be fit into 212 5 times, resulting in a remainder of 12.
Put 5 as the next digit of the answer. 
Result so far: 1995.0
Subtract 200 from 212 to get 12.
Take the next digit (9) from the dividend and append it to 12, then repeat: 129 / 40

Moving on to step 6:
If we divide 129 by 40, we get 3 and a remainder of 9.
Write down 3 as next digit of the result. 
Result so far: 19953.0
If we take 120 away from 129, we end up with 9.
Since there are no more digits in the dividend, we add a zero to the remainder making it 90, and continue the process.

Advancing to step 7:
40 goes into 90 2 times with a remainder of 10.
Write down 2 as next digit of the result. 
Result so far: 19953.2
Deduct 80 from 90 and we're left with 10.
Since there are no more digits in the dividend, we add a zero to the remainder making it 100, and continue the process.

Advancing to step 8:
If we divide 100 by 40, we get 2 and a remainder of 20.
Record the quotient 2 as the next digit in the result. 
Result so far: 19953.22
Subtracting 80 from 100 leaves us with 20.
Since there are no more digits in the dividend, we add a zero to the remainder making it 200, and continue the process.

The final result is 19953.22 with a remainder of 0.02.