A
Alex
Hello, I'm new to Perl
I have a small program, which uses only (big) integers, but works
differently with "use bigint" and "use bignum". Can you please explain
why?
sub Next($)
{
my $var = shift;
my $tst = $var % 2;
return ($tst == 0) ? $var / 2 : $var * 3 + 1;
}
my $n = 2 ** 1000 - 1;
my $counter = 0;
while (1)
{
$n = Next($n);
if ($n == 1)
{
print("counter = ", $counter, "\n");
last;
}
$counter++;
}
Thank you in advance
Alex
I have a small program, which uses only (big) integers, but works
differently with "use bigint" and "use bignum". Can you please explain
why?
sub Next($)
{
my $var = shift;
my $tst = $var % 2;
return ($tst == 0) ? $var / 2 : $var * 3 + 1;
}
my $n = 2 ** 1000 - 1;
my $counter = 0;
while (1)
{
$n = Next($n);
if ($n == 1)
{
print("counter = ", $counter, "\n");
last;
}
$counter++;
}
Thank you in advance
Alex