# highest power of x of a number k that is less than n

For this code:

   a = IntegerExponent[k,7]; (*a is highest power of 7 that divides k*)


I would like to find b, where b is:

   b = IntegerPower[k,7]; (*b is highest power of 7 that is less than k*)


Is there an efficient way to implement a function to do that?

cheers, Jamie

IntegerPower[k_, b_] := If[IntegerQ[#], # - 1, Floor[#]] &@Rationalize[Log[b, k]];

IntegerPower[345, 7] (* Outputs 3 *)