← Back to List

17466번: N! mod P (1) ↗

Solutions

C++14
185 B | 185 chars
#include <iostream>
using namespace std;
typedef long long ll;
ll N,P,K=1;
int main() {
    cin >> N >> P;
    for(int x=2; x<=N; x++) {
        K*=x;
        K%=P;
    }
    cout<<K;
}