You have a mistake in the algorithm description. Here you are: i is equal to 0 while (the octal number is not 0) { the octal number = the decimal number + (remainder of the division of the octal number by 10) * 8 to the power of i the octal number = the octal number / 10 increase i by 1 } It must be decimal number there.