Logarithm tricks for Competitive Programming | Python3 implementation count the number of digits in a number ; Function to count the number of digits in a number ; Driver code
import math NEW_LINE def countDigit ( n ) : NEW_LINE INDENT return ( math . floor ( math . log10 ( n ) + 1 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 80 NEW_LINE print ( countDigit ( n ) ) NEW_LINE DEDENT