in reply to Re^3: why is my for loop using modulo giving me a weird output
in thread why is my for loop using modulo giving me a weird output
totally mistaken on modulo.my bad..
I get it and thank you!
I guess , what I wanted to get out of this was the quotient NOT the remainder
so if I divide the number 20 by 5, I want the quotient 4. ok, let me try this again
then ,next step, is to write a program to find the smallest number that are evenly divided by all the given max_range numbers. ie: like 0-10.
use strict; use warnings; use integer; use constant number => 5; my %result; for ( my $i=0; $i<=20 ;$i++){ #my ($quo, $rem)= ($i/5, $i%5); #need to understand modulo #print "this is quotient",$quo,"when this is divident $i \n"; #print "this is remainder",$rem,"\n"; if ($i%5==0 && $i!=0){ print "this is the quotient",$i/5,"\n"; print "this is the divident",$i,"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: why is my for loop using modulo giving me a weird output
by marinersk (Priest) on Jun 28, 2015 at 08:50 UTC | |
by perlynewby (Scribe) on Jun 28, 2015 at 09:51 UTC | |
by ww (Archbishop) on Jun 28, 2015 at 11:35 UTC | |
by marinersk (Priest) on Jun 29, 2015 at 14:29 UTC |