in reply to Re: Simple arithmetic?
in thread Simple arithmetic?
Exactly, and one can also utilize the fact that 4096 is a power of 2:
$lcm = $r * 4096; $lcm /= 2 until $lcm % 8192; $c = int( $s/$lcm) * $lcm;
UPDATE: 7 hours of sleep later, here is what I wanted to say, but Anonymous Monk has posted it already in node 1119206.
use strict; use warnings; my $s = 3221225472; my $r = 5007; my $lcm = $r; my $m = 0; $lcm/=2 while 12>$m++ and !($lcm%2); $lcm *= 4096; my $c = int( $s/$lcm ) * $lcm; print "$c\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Simple arithmetic?
by BrowserUk (Patriarch) on Mar 08, 2015 at 12:20 UTC |