Sum of the digits of square of the given number which has only 1 's as its digits | C # implementation of the approach ; Function to return the sum of the digits of num ^ 2 ; To store the number of 1 's ; Find the sum of the digits of num ^ 2 ; Driver code
using System ; class GFG { static long squareDigitSum ( String s ) { long lengthN = s . Length ; long result = ( lengthN / 9 ) * 81 + ( long ) Math . Pow ( ( lengthN % 9 ) , 2 ) ; return result ; } public static void Main ( String [ ] args ) { String s = "1111" ; Console . WriteLine ( squareDigitSum ( s ) ) ; } }