Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Mennyi 6789^8642 és 6789^8679 utolsó két számjegye?
- * utolso 2 szamjegy --> mod 100
- */
- #include <stdio.h>
- void keres(int x, int ad, int mod) {
- int i, temp;
- // x^1:
- temp = x % mod;
- // x^2 .. ad
- for (i = 2; i <= ad; i++) {
- temp = (temp * x) % mod;
- }
- printf("%i.: %i\n", ad, temp);
- }
- main()
- {
- keres(6789, 8642, 100);
- keres(6789, 8679, 100);
- return 0;
- }
- /*
- $ ./a.out
- 8642.: 21
- 8679.: 9
- */
Advertisement
Add Comment
Please, Sign In to add comment