Advertisement
bnghtz

matek_hatvany_mod100.pl

Nov 24th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.39 KB | None | 0 0
  1. # Mennyi 6789^8642 és 6789^8679 utolsó két számjegye?
  2. # utolso 2 szamjegy --> mod 100
  3.  
  4. sub keres($$$) {
  5.     ($x, $ad, $mod) = @_;
  6.    
  7.     # x^1:
  8.     $temp = $x % $mod;
  9.     # x^2 .. ad:
  10.     foreach (2 .. $ad) {
  11.         $temp *= $x;
  12.         $temp %= $mod;
  13.     }
  14.    
  15.     print "$temp\n";
  16. }
  17.  
  18. keres(6789, 8642, 100);
  19. keres(6789, 8679, 100);
  20.  
  21.  
  22. # >hatvany_utso2.pl
  23. # 21
  24. # 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement