C # program for the above approach
using System ; using System . Collections . Generic ; class GFG { static int factorial ( int n ) { int ans = 1 ; while ( n >= 1 ) { ans *= n ; n -- ; } return ans ; }