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

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

Moving on to step 2:
The number 40 fits into 39 0 times, leaving a remainder of 39.
The number 0 becomes the next digit in our result. 
Result so far: 0.0
The remainder is 39 after subtracting 0 from 39.
Append the next digit (7) from the dividend to 39 and continue with: 397 / 40

Moving on to step 3:
When dividing 397 by 40, we get 9 with a remainder of 37.
The next digit of our result is 9. 
Result so far: 9.0
The remainder is 37 after subtracting 360 from 397.
Fetch the next digit (9) from the dividend, attach it to 37 and continue: 379 / 40

On to step 4:
379 divided by 40 is 9 with a remainder of 19.
Use 9 as the next digit of our solution. 
Result so far: 99.0
If we subtract 360 from 379, we get 19.
Fetch the next digit (6) from the dividend, attach it to 19 and continue: 196 / 40

Going ahead to step 5:
When dividing 196 by 40, we get 4 with a remainder of 36.
The next digit of our result is 4. 
Result so far: 994.0
Subtract 160 from 196 to get 36.
Fetch the next digit (6) from the dividend, attach it to 36 and continue: 366 / 40

Let's proceed to step 6:
The number 40 fits into 366 9 times, leaving a remainder of 6.
Use 9 as the next digit of our solution. 
Result so far: 9949.0
Subtract 360 from 366 to get 6.
Since there are no more digits in the dividend, we add a zero to the remainder making it 60, and continue the process.

Going ahead to step 7:
The number 40 fits into 60 1 times, leaving a remainder of 20.
Put 1 as the next digit of the answer. 
Result so far: 9949.1
Deduct 40 from 60 and we're left 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.

Moving on to step 8:
When dividing 200 by 40, we get 5 with a remainder of 0.
Put 5 as the next digit of the answer. 
Result so far: 9949.15
The remainder is 0 after subtracting 200 from 200.
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 9:
If we divide 0 by 40, we get 0 and a remainder of 0.
Put 0 as the next digit of the answer. 
Result so far: 9949.15
If we take 0 away from 0, we end up 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.

Let's proceed to step 10:
0 divided by 40 is 0 with a remainder of 0.
The next digit of our result is 0. 
Result so far: 9949.15
Deduct 0 from 0 and we're left 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.

Our division results in 9949.15 with a remaining 0.0.