aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvettes13 <86648326+corvettes13@users.noreply.github.com>2021-08-17 03:36:10 -0500
committerGitHub <noreply@github.com>2021-08-17 03:36:10 -0500
commit8c9ede5b36bcca1030ec86cee0e0bb9c60381f1c (patch)
treee523b853e6ab1f88f2b20caf4bdab87f47789fec
parent98fd79b532d89799663b9dd0183581689e75fca2 (diff)
downloadperlweeklychallenge-club-8c9ede5b36bcca1030ec86cee0e0bb9c60381f1c.tar.gz
perlweeklychallenge-club-8c9ede5b36bcca1030ec86cee0e0bb9c60381f1c.tar.bz2
perlweeklychallenge-club-8c9ede5b36bcca1030ec86cee0e0bb9c60381f1c.zip
Create ch-1.pl
-rw-r--r--challenge-126/paul-fajman/perl/ch-1.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-126/paul-fajman/perl/ch-1.pl b/challenge-126/paul-fajman/perl/ch-1.pl
new file mode 100644
index 0000000000..9970f0f991
--- /dev/null
+++ b/challenge-126/paul-fajman/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# Weekly Challenge 126 Task #1
+# You are given a positive integer $N.
+# Write a script to print count of numbers from 1 to $N that don’t contain digit 1.
+
+use strict;
+use warnings;
+
+die "\nPlease provide positive integer for input\n" if (!@ARGV);
+my $number = $ARGV[0];
+my $i;
+
+my @nums = (2..$number); # Create array of numbers from 2 up to user input number.
+my @final = grep(!/1/, @nums); # Create new array not including numbers that have a 1.
+
+my $count = scalar @final; # Get length of new array.
+
+print "Input: \$N = $number\n";
+print "Output: $count\n\n";
+
+print "There are $count numbers between 1 and $number that don't contain the digit 1\n";
+print "@final\n";