[ create a new paste ] login | about

Link: http://codepad.org/UM6GPQHM    [ 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 = 4;
sub fattoriale
{
    local $valore = $_[0];
    if ($valore > 1)
      {
        return ($valore * &fattoriale ($valore -1));
      }
    else
      {
        return 1;
      }
}

$miofatt = &fattoriale ($input_1);

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


Output:
1
4! = 24


Create a new paste based on this one


Comments: