Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
階乗を求める
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
chomp(my $i = <STDIN>);
say get_fact($i);
sub get_fact{
my $i = shift;
if ($i != 1){
return get_fact($i - 1) * $i;
} else {
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.