Count of digits after concatenation of first N positive integers | C ++ program to find the number of digits after concatenating the first N positive integers ; Function to find the number of digits after concatenating the first N positive integers ; Driver code
#include <iostream> NEW_LINE #include <math.h> NEW_LINE using namespace std ; void numberOfDigits ( int N ) { int nod = floor ( log10 ( N ) + 1 ) ; int toDecrease = ( pow ( 10 , nod ) - 1 ) / 9 ; cout << ( N + 1 ) * nod - toDecrease << endl ; } int main ( ) { int N = 13 ; numberOfDigits ( N ) ; return 0 ; }