Expected Number of Trials to get N Consecutive Heads | Java implementation of the above approach ; Driver Code ; Formula for number of trails for N consecutive heads
class GFG { public static void main ( String [ ] args ) { int N = 3 ; System . out . print ( Math . pow ( 2 , N + 1 ) - 2 ) ; } }