Smallest number whose sum of digits is square of N | Function to return smallest number whose sum of digits is n ^ 2 ; Driver Code
function smallestNum ( n ) { return parseInt ( n * n % 9 + 1 ) * Math . pow ( 10 , parseInt ( n * n / 9 ) ) - 1 ; } let n = 4 ; document . write ( smallestNum ( n ) ) ;