[ create a new paste ] login | about

Link: http://codepad.org/SEqAr144    [ raw code | output | fork ]

appunti2 - Perl, pasted on Apr 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
$input_1 = 3;
sub fattoriale
{
    my $valore = $_[0];
    if ($valore > 1)
      {
        return ($valore * &fattoriale ($valore -1));
      }
    else
      {
        return 1;
      }
}

$miofatt = &fattoriale ($input_1);

print "$input_1! = $miofatt\n";


Output:
1
3! = 6


Create a new paste based on this one


Comments: