Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created April 13, 2019 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/48490d93373cd0dbe4674d6c7f5301bf to your computer and use it in GitHub Desktop.
Save tomcha/48490d93373cd0dbe4674d6c7f5301bf to your computer and use it in GitHub Desktop.
階乗を求める
#!/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