Find the good permutation of first N natural numbers | Function to print the good permutation of first N natural numbers ; If n is odd ; Otherwise ; Driver code
< ? php function printPermutation ( $ n ) { if ( $ n % 2 != 0 ) { echo ( " - 1" ) ; } else for ( $ i = 1 ; $ i <= $ n / 2 ; $ i ++ ) { echo ( 2 * $ i . " ▁ " . ( ( 2 * $ i ) - 1 ) . " ▁ " ) ; } return $ n ; } $ n = 4 ; printPermutation ( $ n ) ; ? >