Find the first natural number whose factorial is divisible by x | A simple C ++ program to find first natural number whose factorial divides x . ; Returns first number whose factorial divides x . ; int i = 1 ; Result ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int firstFactorialDivisibleNumber ( int x ) { int fact = 1 ; for ( i = 1 ; i < x ; i ++ ) { fact = fact * i ; if ( fact % x == 0 ) break ; } return i ; } int main ( void ) { int x = 16 ; cout << firstFactorialDivisibleNumber ( x ) ; return 0 ; }