Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

factorial calculator c++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fact(ll a){
    ll ans = 1;
    ll curr = 1;
    while(a--){
        ans *= curr;
        curr++;
    }
    return ans;
}
int main(){
  	int x;
  	cin >> x;
  	cout << fact(x) ;
}
Source by www.cplusplus.com #
 
PREVIOUS NEXT
Tagged: #factorial #calculator
ADD COMMENT
Topic
Name
6+5 =