[go: up one dir, main page]

login
A246866
Bitmasks that can be used to generate a sequence of all positive integers up to 2^n.
0
3, 6, 12, 20, 48, 96, 184, 272, 576, 1280, 3232, 6912, 13568, 24576, 46080, 73728, 132096, 466944, 589824, 1310720, 3145728, 4194304, 14155776, 18874368, 59244544, 119537664, 150994944, 335544320, 847249408, 1207959552, 2734686208
OFFSET
2,1
COMMENTS
The sequence skips around in a simple pseudo-random order hitting each number from 1 to 2^n exactly once, which makes it suitable for use in e.g. a dissolve-style pixel graphics effect.
JavaScript code to generate all numbers from 1 to 2^n using XOR_MASK, an element of this sequence:
var i = 1; do { i = (i >> 1) ^ (i & 1 ? XOR_MASK : 0); } while (i != 1);
First few numbers of this sequence in hexadecimal, for searchability: 0x03, 0x06, 0x0C, 0x14, 0x30, 0x60, 0xB8, 0x0110, 0x0240, ...
REFERENCES
Andrew S. Glassner, Graphics Gems, Academic Press, 1990, pages 221-232.
CROSSREFS
Sequence in context: A028924 A034738 A054064 * A053479 A290768 A070333
KEYWORD
more,nonn
AUTHOR
James Nylen, Sep 05 2014
STATUS
approved