Advertisement
paperline27

Menghitung.Faktorial.pl

Feb 25th, 2024
1,471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.25 KB | Source Code | 0 0
  1. sub factorial {
  2.     my $n = shift;
  3.     return 1 if $n == 0;
  4.     return $n * factorial($n - 1);
  5. }
  6.  
  7. print "Masukkan bilangan: ";
  8. my $input = <STDIN>;
  9. chomp($input);
  10.  
  11. my $result = factorial($input);
  12. print "Faktorial dari $input adalah $result\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement