Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.30 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. sub euclid {
  4.     ($b, $a) = @_;
  5.     ($b, $a) = ($a, $b) if $b < $a;
  6.     $d = int($b / $a);
  7.     $r = $b % $a;
  8.     print "\\indent{}\\indent{}\$$b = $d($a) + $r\$\\\\\n";
  9.     euclid($a, $r) if $r;
  10. }
  11.  
  12. euclid(@ARGV);
  13. print "\\indent{}\\indent{}gcd($ARGV[0], $ARGV[1]) = $a\\\\\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement