Changing largeInteger from 29 1's to 30 1's changes the type of the variable from Decimal to Double.
Use $largeInteger.GetType() to see that.
The math in the algorithm does not work so fine on doubles. Run the 2 lines in the loop repeatedly on the prompt to see the values in each step.
Once largeInteger goes from decimal to double, the arithmetic is not precise any more. That is why I suggested runnning the 2 lines on the prompt.
Here is the output -
PS C:> $largeInteger % [double]10
8
PS C:> $largeInteger % [double]100
88
PS C:> $largeInteger % [double]1000000000000000000
1.11105501764518E+17
PS C:> $largeInteger % [double]1000000000000000000000
1.11111105501765E+20
PS C:> $largeInteger % [double]1000000000000000000000000000
1.11111111111104E+26
PS C:> $largeInteger % [double]100000000000000000000000000000
1.11111111111111E+28
PS C:> $largeInteger % [double]1000000000000000000000000000000
1.11111111111111E+29
You can see the distortion that occurs due to the internal imprecise representation of the double which cannot be accurately represented in binary. As the divisor increases the accuracy of the increasing remainder also improves.