Minimum value of K such that sum of cubes of first K natural number is greater than equal to N | Java program to determine the minimum value of K such that the sum of cubes of first K natural number is greater than or equal to N ; Function to determine the minimum value of K such that the sum of cubes of first K natural number is greater than or equal to N ; Variable to store the sum of cubes ; Loop to find the number K ; If C is just greater then N , then break the loop ; Driver code
class GFG { static int naive_find_x ( int N ) { int c = 0 , i ; for ( i = 1 ; i < N ; i ++ ) { c += i * i * i ; if ( c >= N ) break ; } return i ; } public static void main ( String [ ] args ) { int N = 100 ; System . out . println ( naive_find_x ( N ) ) ; } }