Find last two digits of sum of N factorials | Function to find the unit ' s ▁ and ▁ ten ' s place digit ; Let us write for cases when N is smaller than or equal to 10. ; We know following ( 1 ! + 2 ! + 3 ! + 4 ! ... + 10 ! ) % 100 = 13 else ( N >= 10 ) ; Driver code
function get_last_two_digit ( N ) { if ( N <= 10 ) { let ans = 0 , fac = 1 ; for ( let i = 1 ; i <= N ; i ++ ) { fac = fac * i ; ans += fac ; } return ans % 100 ; } return 13 ; } let N = 1 ; for ( N = 1 ; N <= 10 ; N ++ ) document . write ( " " + N + " " + get_last_two_digit ( N ) + " " ) ;