jeudi 29 octobre 2015

Detect and print the multiples of a specific integer in Perl

I am trying to write a script that will detect the multiples of an integer that a user entered and is in the range of 200-100. I think I am missing something in my if statement because its not detecting any results for me.

use strict;

use warnings;

print "Enter an integer: ";

my $integer = ;

chomp $integer;

my @nums = (200..100);

my $i = 200;

while($i < $#nums) {

print "$nums[$i]  ";

++$i;

}

if ($i % $integer == 0){

print "$i\n";

}

Aucun commentaire:

Enregistrer un commentaire