Coding Challenge Day

Nick came up with a series of coding challenges ranging from basic (Hello World, a factorial calculator) to advanced (an RSA encryption algorithm) and we chose Perl as a coding language, since none of us knew it. Using built-in help pages and examples from the internet, we tackled these problems and learned basic Perl syntax!

Here's a factorial calculator, demonstrating recursion:

#!/usr/bin/perl

$input = $ARGV[0];

sub factorial{
	my $num=shift;
	if ($num == 0){return 1;}
	else {return $num * factorial($num-1);}
}

print factorial($input);
print "\n"



Creative Commons License
This site is licensed under a Creative Commons Attribution 4.0 International License.