Number of sequences which has HEAD at alternate positions to the right of the first HEAD | Java program to find number of sequences ; function to calculate total sequences possible ; Value of N is even ; Value of N is odd ; Driver code
import java . io . * ; class GFG { static int findAllSequence ( int N ) { if ( N % 2 == 0 ) { return ( int ) ( Math . pow ( 2 , N / 2 + 1 ) + Math . pow ( 2 , N / 2 ) - 2 ) ; } else { return ( int ) ( Math . pow ( 2 , ( N + 1 ) / 2 ) + Math . pow ( 2 , ( N + 1 ) / 2 ) - 2 ) ; } } public static void main ( String [ ] args ) { int N = 2 ; System . out . print ( findAllSequence ( N ) ) ; } }