We look at the division of 791164 by 40 
The aim is to understand the frequency of 40 in 791164.

Moving on to step 1:
The number 40 fits into 7 0 times, leaving a remainder of 7.
Record the quotient 0 as the next digit in the result. 
Result so far: 0.0
The remainder is 7 after subtracting 0 from 7.
Take the next digit (9) from the dividend and append it to 7, then repeat: 79 / 40

Step 2:
40 can be fit into 79 1 times, resulting in a remainder of 39.
Write down 1 as next digit of the result. 
Result so far: 1.0
Subtracting 40 from 79 leaves us with 39.
Take the next digit (1) from the dividend and append it to 39, then repeat: 391 / 40

Advancing to step 3:
If we divide 391 by 40, we get 9 and a remainder of 31.
Write down 9 as next digit of the result. 
Result so far: 19.0
If we take 360 away from 391, we end up with 31.
Fetch the next digit (1) from the dividend, attach it to 31 and continue: 311 / 40

On to step 4:
40 goes into 311 7 times with a remainder of 31.
Use 7 as the next digit of our solution. 
Result so far: 197.0
If we take 280 away from 311, we end up with 31.
Fetch the next digit (6) from the dividend, attach it to 31 and continue: 316 / 40

Going ahead to step 5:
316 divided by 40 is 7 with a remainder of 36.
Record the quotient 7 as the next digit in the result. 
Result so far: 1977.0
If we take 280 away from 316, we end up with 36.
Grab the next digit (4) from the dividend, add it to 36, then carry on: 364 / 40

Going ahead to step 6:
When dividing 364 by 40, we get 9 with a remainder of 4.
Use 9 as the next digit of our solution. 
Result so far: 19779.0
Subtract 360 from 364 to get 4.
Since there are no more digits in the dividend, we add a zero to the remainder making it 40, and continue the process.

Going ahead to step 7:
When dividing 40 by 40, we get 1 with a remainder of 0.
Put 1 as the next digit of the answer. 
Result so far: 19779.1
Subtracting 40 from 40 leaves us with 0.
Since there are no more digits in the dividend, we add a zero to the remainder making it 0, and continue the process.

On to step 8:
If we divide 0 by 40, we get 0 and a remainder of 0.
The number 0 becomes the next digit in our result. 
Result so far: 19779.1
Subtract 0 from 0 to get 0.
Since there are no more digits in the dividend, we add a zero to the remainder making it 0, and continue the process.

Let's proceed to step 9:
When dividing 0 by 40, we get 0 with a remainder of 0.
The number 0 becomes the next digit in our result. 
Result so far: 19779.1
Subtract 0 from 0 to get 0.
Since there are no more digits in the dividend, we add a zero to the remainder making it 0, and continue the process.

The final outcome is 19779.1, with a leftover of 0.0.