login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A254109 If n <= 63, a(n) = n; for n > 63: a(32n + 14) = 8*n + 5, a(64n + 30) = 4*n + 3, and for other cases with n > 63: a(2n) = 2*a(n), a(2n+1) = 2*a(n) + 1. 3
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 21, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 7 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

This sequence is a rewriting-recurrence which attempts to contract the perimeter of binary boundary coded holeless polyhexes and other fusenes by 2 or 4 edges, where first possible (from the least significant end of n), and if no such contraction is possible, then it fixes n. Together with recurrence A258009 can be used to obtain the terms of A258012, please see comments there.

LINKS

Antti Karttunen, Table of n, a(n) for n = 0..8191

FORMULA

If n <= 63, a(n) = n; for n > 63: a(32n + 14) = 8*n + 5, a(64n + 30) = 4*n + 3, and for other cases with n > 63: a(2n) = 2*a(n), a(2n+1) = 2*a(n) + 1.

EXAMPLE

The first term where a(n) is different from n occurs at n=78, as 78 = "1001110" in binary, where the clause a(32n + 14) = 8*n + 5 will rewrite the trailing "01110" part as "101", resulting binary string "10101" = 21 in decimal.

PROG

(Scheme, two variants, the first one utilizing a memoizing definec-macro)

(definec (A254109 n) (cond ((<= n 63) n) ((= 14 (modulo n 32)) (+ 5 (* 8 (floor->exact (/ n 32))))) ((= 30 (modulo n 64)) (+ 3 (* 4 (floor->exact (/ n 64))))) (else (+ (modulo n 2) (* 2 (A254109 (floor->exact (/ n 2))))))))

;; Faster, iterative version:

(define (A254109 n) (let loop ((n n) (s 0) (p2 1)) (cond ((<= n 63) (+ (* p2 n) s)) ((= 14 (modulo n 32)) (+ (* p2 8 (floor->exact (/ n 32))) s (* p2 5))) ((= 30 (modulo n 64)) (+ (* p2 4 (floor->exact (/ n 64))) s (* p2 3))) ((even? n) (loop (/ n 2) s (+ p2 p2))) (else (loop (/ (- n 1) 2) (+ s p2) (+ p2 p2))))))

CROSSREFS

Cf. A255561, A255568, A258009, A258012.

Sequence in context: A000027 A001477 A087156 * A317945 A296086 A292579

Adjacent sequences:  A254106 A254107 A254108 * A254110 A254111 A254112

KEYWORD

nonn,base

AUTHOR

Antti Karttunen, Mar 11 2015

EXTENSIONS

Recurrence corrected to match the intended usage by Antti Karttunen, Jun 05 2015

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 18 07:58 EDT 2018. Contains 316307 sequences. (Running on oeis4.)