0
$\begingroup$

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

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

Examples

IntegerPower[345, 7] (* Outputs 3 *)
IntegerPower[0.0028, 7] (* Outputs -4 *)
IntegerPower[100, 2] (* Outputs 6 *)
IntegerPower[0.5, 2] (* Outputs -2 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.