#!/usr/bin/perl

print "This recursive routine finds the nth pascal number in the rth row.\n";
print "Enter r: "; $r = <STDIN>; chomp($r);
print "Enter n: "; $n = <STDIN>; chomp($n);

$p = pascal($r, $n);

print "The nth pascal number in row $r is $p.\n";

sub pascal {
  my($a, $b) = @_;
  if($b == 0 or $a == $b) {
    return 1;
  } else {
    return pascal($a - 1, $b) + pascal($a - 1, $b - 1);
  }
}
