This site is supported by donations to The OEIS Foundation.
Lodumo transform
The Lodumom transform of a sequence s(n) (sometimes written lodm s) is defined by a(n) = smallest nonnegative integer not yet in the list a such that a(n) ≡ s(n) (mod m). It is not a standard transformation from the mathematical literature, but is occasionally used in the OEIS. It was created by Philippe Deléham.
It creates a sequence without duplicates which is equivalent to the original sequence mod m. The resulting sequence is a permutation of the nonnegative integers if and only if all residue classes mod m appear infinitely often in the original sequence.
Maple
# @param L the input list of non-negative numbers # @param m the remainder of the modulo operation. This is only useful # if it's a number larger than 1. # @return the sequence of nonnegative numbers a(n) # # Example: generate A160016 from A159833: # A159833 := [seq(n^2*(n^2+15)/4,n=0..100) ]; # LODUMO(A159833,2) ; # # Example: generate A160081 from A000045: # A000045 := [seq(combinat[fibonacci](n),n=0..100) ]; # LODUMO(A000045,5) ; # # Richard J. Mathar, 2009-04-30 LODUMO := proc(L,m) local a,n, an; if not type(L,'list') then ERROR("Expected list type argument instead of ",whattype(L) ) ; end if; a := [] ; for n from 1 to nops(L) do for an from op(n,L) mod m by m do if not an in a then a := [op(a),an] ; break; fi; od: end do; a ; end proc:
Perl
sub lodumo { # Georg Fischer, Feb 15 2019 my ($m, @list) = @_; my @a = (); my $il = 0; while ($il < scalar(@list)) { my $busy = 1; my $an = $list[$il] % $m; while ($busy == 1) { if (scalar(grep {$_ == $an} @a) == 0) { push(@a, $an); $busy = 0; } $an += $m; } # while $busy $il ++; } # while return @a; } # sub lodumo my @a = &lodumo($m, @list); for (my $n = 0; $n < scalar(@list); $n ++) { print "$n $a[$n]\n"; } # for
Cite this as
Charles R Greathouse IV and Georg Fischer, Lodumo transform.— From the On-Line Encyclopedia of Integer Sequences® Wiki (OEIS® Wiki). [https://oeis.org/wiki/Lodumo_transform]