cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A258136 Lexicographically earliest sequence of odd positive integers such that the terms and their absolute first differences are all distinct.

This page as a plain text file.
%I A258136 #19 Dec 23 2024 14:53:44
%S A258136 1,3,7,13,5,15,27,9,23,39,11,31,53,17,41,67,19,49,81,21,55,93,25,65,
%T A258136 107,29,73,119,33,83,135,35,89,145,37,95,157,43,109,45,115,187,47,121,
%U A258136 197,51,131,213,57,141,229,59,149,241,61,155,251,63,161,263,69
%N A258136 Lexicographically earliest sequence of odd positive integers such that the terms and their absolute first differences are all distinct.
%H A258136 Alois P. Heinz, <a href="/A258136/b258136.txt">Table of n, a(n) for n = 1..1000</a>
%H A258136 Eric Angelini, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2015-May/014890.html">Derangements</a> on the SeqFan list, May 21 2015.
%F A258136 a(n) = 2*A081145(n)-1.
%p A258136 b:= proc() false end:
%p A258136 a:= proc(n) option remember; local k;
%p A258136       if n=1 then b(1):= true; 1
%p A258136     else a(n-1); for k while b(k) or
%p A258136          b(abs(a(n-1)-k)) by 2 do od;
%p A258136          b(k), b(abs(a(n-1)-k)):= true$2; k
%p A258136       fi
%p A258136     end:
%p A258136 seq(a(n), n=1..101);
%t A258136 b[_] = False;
%t A258136 a[n_] := a[n] = Module[{k},
%t A258136      If[n == 1, b[1] = True; 1,
%t A258136      a[n-1]; For[k = 1, b[k] ||
%t A258136      b[Abs[a[n-1] - k]], k += 2];
%t A258136      {b[k], b[Abs[a[n-1] - k]]} = {True, True}; k]];
%t A258136 Table[a[n], {n, 1, 101}] (* _Jean-François Alcover_, Aug 01 2021, after _Alois P. Heinz_ *)
%Y A258136 Cf. A081145, A258137 (absolute first differences), A257941, A257944.
%K A258136 nonn
%O A258136 1,2
%A A258136 _Eric Angelini_ and _Alois P. Heinz_, May 21 2015