512865 ÷ 40 
Let's see how many times 40 fits into 512865.

Moving on to step 1:
40 can be fit into 5 0 times, resulting in a remainder of 5.
The next digit of our result is 0. 
Result so far: 0.0
Subtracting 0 from 5 leaves us with 5.
Grab the next digit (1) from the dividend, add it to 5, then carry on: 51 / 40

Advancing to step 2:
40 can be fit into 51 1 times, resulting in a remainder of 11.
Record the quotient 1 as the next digit in the result. 
Result so far: 1.0
Deduct 40 from 51 and we're left with 11.
Grab the next digit (2) from the dividend, add it to 11, then carry on: 112 / 40

Let's proceed to step 3:
If we divide 112 by 40, we get 2 and a remainder of 32.
The number 2 becomes the next digit in our result. 
Result so far: 12.0
The remainder is 32 after subtracting 80 from 112.
Fetch the next digit (8) from the dividend, attach it to 32 and continue: 328 / 40

Going ahead to step 4:
The number 40 fits into 328 8 times, leaving a remainder of 8.
Record the quotient 8 as the next digit in the result. 
Result so far: 128.0
The remainder is 8 after subtracting 320 from 328.
Fetch the next digit (6) from the dividend, attach it to 8 and continue: 86 / 40

Moving on to step 5:
86 divided by 40 is 2 with a remainder of 6.
The number 2 becomes the next digit in our result. 
Result so far: 1282.0
The remainder is 6 after subtracting 80 from 86.
Append the next digit (5) from the dividend to 6 and continue with: 65 / 40

Advancing to step 6:
The number 40 fits into 65 1 times, leaving a remainder of 25.
Use 1 as the next digit of our solution. 
Result so far: 12821.0
The remainder is 25 after subtracting 40 from 65.
Since there are no more digits in the dividend, we add a zero to the remainder making it 250, and continue the process.

On to step 7:
If we divide 250 by 40, we get 6 and a remainder of 10.
Put 6 as the next digit of the answer. 
Result so far: 12821.6
If we subtract 240 from 250, we get 10.
Since there are no more digits in the dividend, we add a zero to the remainder making it 100, and continue the process.

Let's proceed to step 8:
40 can be fit into 100 2 times, resulting in a remainder of 20.
Record the quotient 2 as the next digit in the result. 
Result so far: 12821.62
Deduct 80 from 100 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 9:
40 goes into 200 5 times with a remainder of 0.
The number 5 becomes the next digit in our result. 
Result so far: 12821.625
If we subtract 200 from 200, 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.

Going ahead to step 10:
40 goes into 0 0 times with a remainder of 0.
Put 0 as the next digit of the answer. 
Result so far: 12821.625
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.

Advancing to step 11:
The number 40 fits into 0 0 times, leaving a remainder of 0.
Write down 0 as next digit of the result. 
Result so far: 12821.625
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 12821.625, with a leftover of 0.0.