login
Simple triangle-stretching N X N -> N bijection: Inverse of A072732.
7

%I #5 May 01 2014 02:47:42

%S 0,1,5,6,2,14,15,3,9,27,28,10,4,20,44,45,21,7,13,35,65,66,36,16,8,26,

%T 54,90,91,55,29,11,19,43,77,119,120,78,46,22,12,34,64,104,152,153,105,

%U 67,37,17,25,53,89,135,189,190,136,92,56,30,18,42,76,118,170,230,231

%N Simple triangle-stretching N X N -> N bijection: Inverse of A072732.

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%o (Scheme) (define (A072733 n) (packA072733 (A025581 n) (A002262 n)))

%o (define (packA001477 x y) (/ (+ (expt (+ x y) 2) x (* 3 y)) 2))

%o (define (packA072733 x y) (cond ((<= x y) (let ((half-x (floor->exact (/ x 2)))) (packA001477 half-x (+ half-x (* 2 (- y (* 2 half-x) (modulo x 2))) (modulo x 2))))) (else (let ((half-y (floor->exact (/ y 2)))) (packA001477 (+ 1 half-y (* 2 (- (-1+ x) (* 2 half-y) (modulo y 2))) (modulo y 2)) half-y)))))

%Y Inverse: A072732, projections: A072738 & A072739, variant of the same theme: A072735. Cf. also A001477 and its projections A025581 & A002262.

%K nonn,tabl

%O 0,3

%A _Antti Karttunen_, Jun 12 2002