Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- long long int n = 21;
- long long int m = 1007;
- long long int hasil = 1;
- for (long long int i = 1; i <= n; i++) {
- hasil = hasil * i;
- }
- printf("Sebelum modulo: %I64d\n", hasil); // Sebelum modulo: -4249290049419214848
- printf("Sesudah modulo: %I64d\n", hasil % m); // Sesudah modulo: -982
- // 9,223,372,036,854,775,807 - batas akhir long long int
- // -4,249,290,049,419,214,848 - 21! (sebelum modulo)
- // 51,090,942,171,709,440,000 - 21! (sebelum modulo) yang sebenarnya
- //
- // -982 - 21! % 1007 (sesudah modulo)
- // 494 - 21! % 1007 (sesudah modulo) yang sebenarnya
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement