- or download this
# encapsulate the mechanics of divisibility testing
use Divisor;
...
$seven->divides( 400*365 + 97 ),
'But the Gregorian calendar repeats itself every 400 years.',
);
- or download this
my $two = Divisor->new(2);
ok( $two->divides('42'), "Two divides '42'." );
...
not( $two->divides('19') ),
"Two does not divide '19'.",
);
- or download this
my $long_string_of_twos = '2' x 320;
TODO: {
local $TODO = 'Redefine divisibility by two.';
...
"Two divides $long_string_of_twos.",
) or diag 'We just contrived an overflow exception.';
}
- or download this
# just look at the last digit, silly!
$two->set_divisibility_test( sub {shift =~ /[02468]$/} );
ok(
$two->divides($long_string_of_twos),
"Two divides $long_string_of_twos, as any fool can see.",
);
- or download this
use strict;
use warnings;
...
}
'Divide et impera!';
- or download this
use strict;
use warnings;
...
$two->divides($long_string_of_twos),
"Two divides $long_string_of_twos, as any fool can see.",
);
- or download this
ok 1 - use Divisor;
ok 2 - The object isa Divisor
...
2222222222222222222222222222222222222222222222222222222222222222222222
+2222222222
2222222222222222222222222222222222222222222222222222222222222222222222
+2222222222
22222222222222222222, as any fool can see.