Finding number of digits in n 'th Fibonacci number | This function returns the number of digits in nth Fibonacci number after ceiling it Formula used ( n * log ( phi ) - ( log 5 ) / 2 ) ; using phi = 1.6180339887498948 ; Driver Code
function numberOfDigits ( n ) { if ( n == 1 ) return 1 ; let d = ( n * Math . log10 ( 1.6180339887498948 ) ) - ( ( Math . log10 ( 5 ) ) / 2 ) ; return Math . ceil ( d ) ; } let i ; for ( let i = 1 ; i <= 10 ; i ++ ) document . write ( ` ${ i } ${ numberOfDigits ( i ) } ` ) ;