findHighestPower n p
    = findHighestPowerAccum bound p 1
    where bound = floor $ (fromIntegral n :: Double) / (fromIntegral p :: Double)
          findHighestPowerAccum bound p accum 
              | accum > bound = accum
              | otherwise     = findHighestPowerAccum bound p (accum * p)
findHighestPower n p
    = findHighestPowerAccum bound p 1
    where bound = floor $ (fromIntegral n :: Double) / (fromIntegral p :: Double)
          findHighestPowerAccum bound p accum 
              | accum > bound = accum
              | otherwise     = findHighestPowerAccum bound p (accum * p)
findHighestPower n p
    = findHighestPowerAccum bound p 1
    where bound = floor $ (fromIntegral n :: Double) / (fromIntegral p :: Double)
          findHighestPowerAccum bound p accum 
              | accum > bound = accum
              | otherwise     = findHighestPowerAccum bound p (accum * p)