Find the sum of the series 1 + 11 + 111 + 1111 + ... . . upto n terms | java program to find the sum of the series 1 + 11 + 111 + 1111 + ... . ; Function for finding summation ; Driver Code
import java . io . * ; class GFG { static int summation ( int n ) { int sum ; sum = ( int ) ( Math . pow ( 10 , n + 1 ) - 10 - ( 9 * n ) ) / 81 ; return sum ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( summation ( n ) ) ; } }