Number of Hamiltonian cycle | Java program for implementation of the above program ; Function that calculates number of Hamiltonian cycle ; Calculating factorial ; Driver code
class GFG { static int Cycles ( int N ) { int fact = 1 , result = 0 ; result = N - 1 ; int i = result ; while ( i > 0 ) { fact = fact * i ; i -- ; } return fact / 2 ; } public static void main ( String [ ] args ) { int N = 5 ; int Number = Cycles ( N ) ; System . out . println ( " Hamiltonian ▁ cycles ▁ = ▁ " + Number ) ; } }