N=given number.

r=Base.

n=number of digit in N.

so 7th complement of octal number 145 is

((r power n)-1)-N.

=((8 power 3)-1)-145

=(512-1)-145

=511-145

=366

r=Base.

n=number of digit in N.

so 7th complement of octal number 145 is

((r power n)-1)-N.

=((8 power 3)-1)-145

=(512-1)-145

=511-145

=366