Created
April 13, 2019 01:02
-
-
Save tomcha/48490d93373cd0dbe4674d6c7f5301bf to your computer and use it in GitHub Desktop.
階乗を求める
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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