diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-08-09 19:53:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-09 19:53:19 +0100 |
| commit | d64691387a0da4422ce8586b2ba2cc7a955dc4a2 (patch) | |
| tree | 348d7baa7d895d9810318a410c017ba4fe8b48c4 /challenge-072 | |
| parent | c758f98a0bcbe7fbe18efb787ac88172d0fd7912 (diff) | |
| parent | 03a932b006644fddefbbfc81d5a456fd632963dc (diff) | |
| download | perlweeklychallenge-club-d64691387a0da4422ce8586b2ba2cc7a955dc4a2.tar.gz perlweeklychallenge-club-d64691387a0da4422ce8586b2ba2cc7a955dc4a2.tar.bz2 perlweeklychallenge-club-d64691387a0da4422ce8586b2ba2cc7a955dc4a2.zip | |
Merge pull request #2055 from adamcrussell/challenge-072
Challenge 072
Diffstat (limited to 'challenge-072')
| -rw-r--r-- | challenge-072/adam-russell/blog1.txt | 1 | ||||
| -rw-r--r-- | challenge-072/adam-russell/input.txt | 100 | ||||
| -rw-r--r-- | challenge-072/adam-russell/perl/ch-1.pl | 26 | ||||
| -rw-r--r-- | challenge-072/adam-russell/perl/ch-2.sh | 1 |
4 files changed, 128 insertions, 0 deletions
diff --git a/challenge-072/adam-russell/blog1.txt b/challenge-072/adam-russell/blog1.txt new file mode 100644 index 0000000000..4f028ef3cc --- /dev/null +++ b/challenge-072/adam-russell/blog1.txt @@ -0,0 +1 @@ +https://adamcrussell.livejournal.com/17058.html diff --git a/challenge-072/adam-russell/input.txt b/challenge-072/adam-russell/input.txt new file mode 100644 index 0000000000..e5a15512e0 --- /dev/null +++ b/challenge-072/adam-russell/input.txt @@ -0,0 +1,100 @@ +L1 +L2 +L3 +L4 +L5 +L6 +L7 +L8 +L9 +L10 +L11 +L12 +L13 +L14 +L15 +L16 +L17 +L18 +L19 +L20 +L21 +L22 +L23 +L24 +L25 +L26 +L27 +L28 +L29 +L30 +L31 +L32 +L33 +L34 +L35 +L36 +L37 +L38 +L39 +L40 +L41 +L42 +L43 +L44 +L45 +L46 +L47 +L48 +L49 +L50 +L51 +L52 +L53 +L54 +L55 +L56 +L57 +L58 +L59 +L60 +L61 +L62 +L63 +L64 +L65 +L66 +L67 +L68 +L69 +L70 +L71 +L72 +L73 +L74 +L75 +L76 +L77 +L78 +L79 +L80 +L81 +L82 +L83 +L84 +L85 +L86 +L87 +L88 +L89 +L90 +L91 +L92 +L93 +L94 +L95 +L96 +L97 +L98 +L99 +L100 diff --git a/challenge-072/adam-russell/perl/ch-1.pl b/challenge-072/adam-russell/perl/ch-1.pl new file mode 100644 index 0000000000..8e8fa79470 --- /dev/null +++ b/challenge-072/adam-russell/perl/ch-1.pl @@ -0,0 +1,26 @@ +use strict; +use warnings; +## +# You are given a positive integer $N (<= 10). +# Write a script to print the number of trailing zeroes in $N!. +## + +sub factorial{ + my($n) = @_; + return 1 if $n == 1; + return $n * factorial($n - 1); +} + +sub count_10s{ + my($n) = @_; + return 2 if $n == 10; + return 1 if $n >=5 && $n < 10; + return 0 if $n < 5; +} + +MAIN:{ + my $n = $ARGV[0]; + my $zeroes = count_10s($n); + print "\$N! = " . factorial($n) . " has $zeroes trailing zero\n" if $zeroes == 1; + print "\$N! = " . factorial($n) . " has $zeroes trailing zeroes\n" if $zeroes > 1 || $zeroes == 0; +} diff --git a/challenge-072/adam-russell/perl/ch-2.sh b/challenge-072/adam-russell/perl/ch-2.sh new file mode 100644 index 0000000000..96118ad9db --- /dev/null +++ b/challenge-072/adam-russell/perl/ch-2.sh @@ -0,0 +1 @@ +perl -s -n -e 'print if $. >= $A && $. <= $B' -- -A=4 -B=12 < input.txt |
