Giai thừa #2

View as PDF

Points: 100 (p) Time limit: 1.0s Memory limit: 256M Input: stdin Output: stdout

Tính \(S=(1!+2!+3!+...+n!) \% mod\)

Input

  • 1 dòng ghi 2 số \(n\), \(mod\) cách nhau 1 dấu cách \((1 \leq n \leq 10)\); \((2 \leq mod \leq 10^9)\)

Output

  • In ra đáp án

Example

Test 1
Input
3 11
Output
9
Test 2
Input
4 10
Output
3

Comments

There are no comments at the moment.