Last active
August 6, 2018 16:10
-
-
Save WindAzure/60e3d9f1fceea5c16f1a5c491e677506 to your computer and use it in GitHub Desktop.
algorithm exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
auto n = 0; | |
const auto modNum = 1000000; | |
while (~scanf("%d", &n)) | |
{ | |
n = n >= 25 ? 25 : n; | |
auto sum = 0; | |
for (auto num = 1; num <= n; num++) | |
{ | |
auto factorial = 1; | |
for (auto multiplier = 2; multiplier <= num; multiplier++) | |
{ | |
factorial = factorial * multiplier % modNum; | |
} | |
sum = (sum + factorial) % modNum; | |
} | |
printf("%d\n", sum); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment