Cisco interview question

How to efficiently implement log function using C?