We're dividing 509150 by 40 
The aim is to understand the frequency of 40 in 509150.

Let's proceed to step 1:
When dividing 5 by 40, we get 0 with a remainder of 5.
Write down 0 as next digit of the result. 
Result so far: 0.0
Deduct 0 from 5 and we're left with 5.
Fetch the next digit (0) from the dividend, attach it to 5 and continue: 50 / 40

Advancing to step 2:
50 divided by 40 is 1 with a remainder of 10.
Use 1 as the next digit of our solution. 
Result so far: 1.0
The remainder is 10 after subtracting 40 from 50.
Include the next digit (9) from the dividend after 10, then repeat: 109 / 40

Moving on to step 3:
40 goes into 109 2 times with a remainder of 29.
The number 2 becomes the next digit in our result. 
Result so far: 12.0
If we subtract 80 from 109, we get 29.
Take the next digit (1) from the dividend and append it to 29, then repeat: 291 / 40

Going ahead to step 4:
If we divide 291 by 40, we get 7 and a remainder of 11.
The next digit of our result is 7. 
Result so far: 127.0
Subtract 280 from 291 to get 11.
Bring next digit (5) of the dividend behind the 11 and repeat the process: 115 / 40

On to step 5:
115 divided by 40 is 2 with a remainder of 35.
The number 2 becomes the next digit in our result. 
Result so far: 1272.0
If we take 80 away from 115, we end up with 35.
Bring next digit (0) of the dividend behind the 35 and repeat the process: 350 / 40

Advancing to step 6:
If we divide 350 by 40, we get 8 and a remainder of 30.
The next digit of our result is 8. 
Result so far: 12728.0
Deduct 320 from 350 and we're left with 30.
Since there are no more digits in the dividend, we add a zero to the remainder making it 300, and continue the process.

Let's proceed to step 7:
40 can be fit into 300 7 times, resulting in a remainder of 20.
Use 7 as the next digit of our solution. 
Result so far: 12728.7
Deduct 280 from 300 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.

Advancing to step 8:
If we divide 200 by 40, we get 5 and a remainder of 0.
The number 5 becomes the next digit in our result. 
Result so far: 12728.75
If we take 200 away from 200, 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.

Step 9:
40 goes into 0 0 times with a remainder of 0.
The number 0 becomes the next digit in our result. 
Result so far: 12728.75
The remainder is 0 after subtracting 0 from 0.
Since there are no more digits in the dividend, we add a zero to the remainder making it 0, and continue the process.

Step 10:
The number 40 fits into 0 0 times, leaving a remainder of 0.
The next digit of our result is 0. 
Result so far: 12728.75
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.

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