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

Advancing to step 1:
If we divide 6 by 40, we get 0 and a remainder of 6.
Record the quotient 0 as the next digit in the result. 
Result so far: 0.0
If we take 0 away from 6, we end up with 6.
Grab the next digit (5) from the dividend, add it to 6, then carry on: 65 / 40

On to step 2:
40 can be fit into 65 1 times, resulting in a remainder of 25.
Put 1 as the next digit of the answer. 
Result so far: 1.0
Subtract 40 from 65 to get 25.
Append the next digit (1) from the dividend to 25 and continue with: 251 / 40

On to step 3:
The number 40 fits into 251 6 times, leaving a remainder of 11.
The number 6 becomes the next digit in our result. 
Result so far: 16.0
The remainder is 11 after subtracting 240 from 251.
Include the next digit (1) from the dividend after 11, then repeat: 111 / 40

Step 4:
When dividing 111 by 40, we get 2 with a remainder of 31.
The number 2 becomes the next digit in our result. 
Result so far: 162.0
If we subtract 80 from 111, we get 31.
Take the next digit (7) from the dividend and append it to 31, then repeat: 317 / 40

On to step 5:
The number 40 fits into 317 7 times, leaving a remainder of 37.
Write down 7 as next digit of the result. 
Result so far: 1627.0
Subtract 280 from 317 to get 37.
Fetch the next digit (6) from the dividend, attach it to 37 and continue: 376 / 40

Going ahead to step 6:
376 divided by 40 is 9 with a remainder of 16.
Use 9 as the next digit of our solution. 
Result so far: 16279.0
Subtracting 360 from 376 leaves us with 16.
Since there are no more digits in the dividend, we add a zero to the remainder making it 160, and continue the process.

On to step 7:
The number 40 fits into 160 4 times, leaving a remainder of 0.
Record the quotient 4 as the next digit in the result. 
Result so far: 16279.4
Deduct 160 from 160 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.

On to step 8:
40 can be fit into 0 0 times, resulting in a remainder of 0.
The next digit of our result is 0. 
Result so far: 16279.4
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.

On to step 9:
The number 40 fits into 0 0 times, leaving a remainder of 0.
Put 0 as the next digit of the answer. 
Result so far: 16279.4
If we subtract 0 from 0, we 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 quotient of the division is 16279.4, and the remainder is 0.0.