Smallest and Largest N | C ++ implementation of the approach ; Function to print the largest and the smallest n - digit perfect cube ; Smallest n - digit perfect cube ; Largest n - digit perfect cube ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void nDigitPerfectCubes ( int n ) { cout << pow ( ceil ( cbrt ( pow ( 10 , ( n - 1 ) ) ) ) , 3 ) << " ▁ " ; cout << ( int ) pow ( ceil ( cbrt ( pow ( 10 , ( n ) ) ) ) - 1 , 3 ) ; } int main ( ) { int n = 3 ; nDigitPerfectCubes ( n ) ; return 0 ; }