LCM of factorial and its neighbors | CPP 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; unsigned int factorial ( unsigned int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } int LCMOfNeighbourFact ( int n ) { return factorial ( n + 1 ) ; } int main ( ) { int N = 5 ; cout << LCMOfNeighbourFact ( N ) << " STRNEWLINE " ; return 0 ; }