Determine the count of Leaf nodes in an N | Java program to find number of leaf nodes ; Function to calculate leaf nodes in n - ary tree ; Driver code
class GfG { static int calcNodes ( int N , int I ) { int result = 0 ; result = I * ( N - 1 ) + 1 ; return result ; } public static void main ( String [ ] args ) { int N = 5 , I = 2 ; System . out . println ( " Leaf ▁ nodes ▁ = ▁ " + calcNodes ( N , I ) ) ; } }