LCM of factorial and its neighbors | Java program to calculate the LCM of N ! and its neighbor ( N - 1 ) ! and ( N + 1 ) ! ; function to calculate the factorial ; returning the factorial of the largest number in the given three consecutive numbers ; Driver code
import java . io . * ; class GFG { static int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } static int LCMOfNeighbourFact ( int n ) { return factorial ( n + 1 ) ; } public static void main ( String args [ ] ) { int N = 5 ; System . out . println ( LCMOfNeighbourFact ( N ) ) ; } }