Find the last two digits of Factorial of a given Number | C ++ implementation to find last two digits factorial of a given number ; Function to print the last two digits of N ! ; For N >= 10 , N ! % 100 will always be 0 ; Calculating N ! % 100 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void lastTwoDigits ( long long N ) { if ( N >= 10 ) { cout << "00" ; return ; } long long fac = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fac = ( fac * i ) % 100 ; cout << fac ; } int main ( ) { int N = 7 ; lastTwoDigits ( N ) ; }