in reply to Nested loops
use ntheory ":all"; use feature "say"; say scalar(grep { gcd($_,13*17*19)==1 } 1..2310);
Seems much easier than all the looping or recursion. The gcd will return 1 if the two inputs have no common factors -- if it isn't divisible by 13, 17, or 19 in this example.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Nested loops
by robert44444uk (Acolyte) on Sep 20, 2015 at 18:56 UTC |
In Section
Seekers of Perl Wisdom