Count of numbers of length N having prime numbers at odd indices and odd numbers at even indices | Java program to Count of numbers of length N having prime numbers at odd indices and odd numbers at even indices ; function to find total number of ways ; No of odd indices in n - digit number ; No of even indices in n - digit number ; No of ways of arranging prime number digits in odd indices ; No of ways of arranging odd number digits in even indices ; returning the total number of ways ; Driver Code
import java . util . * ; class GFG { static int find_Numb_ways ( int n ) { int odd_indices = n / 2 ; int even_indices = ( n / 2 ) + ( n % 2 ) ; int arr_odd = ( int ) Math . pow ( 4 , odd_indices ) ; int arr_even = ( int ) Math . pow ( 5 , even_indices ) ; return arr_odd * arr_even ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . print ( find_Numb_ways ( n ) ) ; } }