Why does Base58 WIF-format of PK have ‘5’ prefix (the standpoint of mathematics)

I’m trying create raw private keys using the steps:

  1. Take a version of PK (0x80) and concatenate (as prefix)with my pseudo-random 32bytes-array.
  2. Take a calculated checksum (4bytes) and push it to the end of the array.
  3. Encode the result to Base58Check using the algorithm:

    code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; x = converted_arrayofbytes_to_big_integer;        output_string = "";         while(x > 0)  {     (x, remainder) = divide(x, 58); //x becomes the integer part of dividing here     output_string.append(code_string[remainder]) }  return  output_string.Reverse(); 

Ok, I have done it, but I can’t understand when x devided into 58 (through the loop) why the last remainder is 4 always (decimal: when the remainder is 4, it use as index of code_string: the last value of output_string is 5 (Base58) therefore)? I assume this’s beacause of version’s prefix but who can explain it from the standpoint of mathematics?

Recent Questions – Bitcoin Stack Exchange