Printing leftmost zeros . Since ( a ^ b ) % k can have digits less then k . In that case we need to print zeros
for ( int i = 0 ; i < k - temp . ToString ( ) . Length ; i ++ ) Console . WriteLine ( 0 ) ;