NAME

Math::NumSeq::MathImageReRound -- sequence from repeated rounding up

SYNOPSIS

use Math::NumSeq::MathImageReRound;
my $seq = Math::NumSeq::MathImageReRound->new;
my ($i, $value) = $seq->next;

DESCRIPTION

This is the sequence of values formed by repeatedly rounding up to a multiple of i-1,i-2,...,2,1.

1, 2, 4, 6, 10, 12,

For example i=5 is rounded up to a multiple of 4 to give 8, then rounded up to a multiple of 3 to give 9, then rounded up to a multiple of 2 for value 10 at i=5.

When rounding up if a value is already a suitable multiple then it's unchanged. For example i=4 round up to a multiple of 3 to give 6, then round up to a multiple of 2 is unchanged 6 since it's already a multiple of 2.

Because the last step rounds up to a multiple of 2 the values are all even. They're also monotonically increasing and end up approximately

value ~= i^2 / pi

though there's values both bigger and smaller than this approximation.

FUNCTIONS

$seq = Math::NumSeq::MathImageReRound->new (key=>value,...)

Create and return a new sequence object.

$bool = $seq->pred($value)

Return true if $value is a ReRound value.

FORMULAS

Predicate

The rounding procedure can be reversed to test for a ReRound value.

for i=2,3,4,etc
  remainder = value mod i
  if remainder==i-1 then not a ReRound
  otherwise
  value -= remainder    # round down to multiple of i
stop when value <= i
is a ReRound if value==i (and i is its index)

For example to test 28, it's a multiple of 2, so ok for the final rounding. It's predecessor in the rounding steps was a multiple of 3, so round down to a multiple of 3 which is 27. The predecessor of 27 was a multiple of 4 so round down to 24. But at that point there's a contradiction because if 24 was the value then it's already a multiple of 3 and so wouldn't have gone up to 27. This case where a round-down gives a multiple of both i and i-1 is identified by the remainder value % i == i-1, since the value is already a multiple of i-1 and subtracting an i-1 would leave it still so.

SEE ALSO

Math::NumSeq