Number of chocolates left after k iterations | Java program to find remaining chocolates after k iterations ; Function to find the chocolates left ; Driver code
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int results ( int n , int k ) { return ( int ) Math . round ( Math . pow ( n , ( 1.0 / Math . pow ( 2.0 , k ) ) ) ) ; } public static void main ( String args [ ] ) { int k = 3 , n = 100000000 ; System . out . print ( " Chocolates ▁ left ▁ after ▁ " + k + " ▁ iterations ▁ are ▁ " + results ( n , k ) ) ; } }