Python
num = int(input())
def factorial(a):
k = 1
for i in range(1, a + 1):
k *= 1
return k
print(factorial(a))
В Python есть более простой :
import math
print(math.factorial(num))
C++
include <bits/stdc++.h>
using namespace std;
long long factorial(long long a) {
long long k = 1;
for (long long i = 1; i <= a; ++i) {
k *= i;
}
return k;
int main() {
long long num, ans;
cin >> num;
ans = factorial(num);
cout << ans;
return 0;
Python
num = int(input())
def factorial(a):
k = 1
for i in range(1, a + 1):
k *= 1
return k
print(factorial(a))
В Python есть более простой :
import math
num = int(input())
print(math.factorial(num))
C++
include <bits/stdc++.h>
using namespace std;
long long factorial(long long a) {
long long k = 1;
for (long long i = 1; i <= a; ++i) {
k *= i;
}
return k;
}
int main() {
long long num, ans;
cin >> num;
ans = factorial(num);
cout << ans;
return 0;
}