%I #5 May 01 2014 02:47:42
%S 0,1,2,3,12,4,7,17,18,5,6,23,40,24,8,11,31,49,50,25,9,10,30,59,84,60,
%T 32,13,16,39,71,97,98,61,33,14,15,38,70,111,144,112,72,41,19,22,48,83,
%U 127,161,162,113,73,42,20,21,47,82,126,179,220,180,128,85,51,26,29,58
%N Simple triangle-stretching N X N -> N bijection, variant of A072732.
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%o (Scheme) (define (A072734 n) (packA072734 (A025581 n) (A002262 n)))
%o (define (packA001477 x y) (/ (+ (expt (+ x y) 2) x (* 3 y)) 2))
%o (define (packA072734 x y) (let ((x-y (- x y))) (cond ((negative? x-y) (packA001477 (+ (* 2 x) (modulo (1+ x-y) 2)) (+ (* 2 x) (floor->exact (/ (+ (- x-y) (modulo x-y 2)) 2))))) ((< x-y 3) (packA001477 (+ (* 2 y) x-y) (* 2 y))) (else (packA001477 (+ (* 2 y) (floor->exact (/ (1+ x-y) 2)) (modulo (1+ x-y) 2)) (+ (* 2 y) (modulo x-y 2)))))))
%Y Inverse: A072735, projections: A072740 & A072741, variant of the same theme: A072732. Used to construct the global arithmetic ranking scheme of plane binary trees presented in A072787/A072788. Cf. also A001477 and its projections A025581 & A002262.
%K nonn,tabl
%O 0,3
%A _Antti Karttunen_, Jun 12 2002
|