Index of smallest triangular number with N digits | C ++ implementation of the above approach ; Function to return index of smallest triangular no n digits ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findIndex ( int n ) { float x = sqrt ( 2 * pow ( 10 , ( n - 1 ) ) ) ; return round ( x ) ; } int main ( ) { int n = 3 ; cout << findIndex ( n ) ; return 0 ; }