#JavaScript (ES6), 59 bytes
We can save 2 bytes by making the sequence 1-indexed and using a simplification similar to the one used by KSab :
n=>(x=g=y=>n?g(y+=y==(x^=y-x),n--):x<y?[x++,...g(y)]:[])(1)
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\operatorname{AND}-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\operatorname{AND}-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 59 bytes
We can save 2 bytes by making the sequence 1-indexed and using a simplification similar to the one used by KSab :
n=>(x=g=y=>n?g(y+=y==(x^=y-x),n--):x<y?[x++,...g(y)]:[])(1)
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\operatorname{AND}-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\text{ AND }-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\operatorname{AND}-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\text{ AND }-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\operatorname{AND}-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\text{ AND }-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
#JavaScript (ES6), 61 bytes
Returns a list of non-wrapping integers.
n=>(g=v=>n?g(u&-u^v?v*2:!!u++,n--):v?[u-v,...g(v-1)]:[])(u=1)
Based upon a construction by Donald Knuth. Related OEIS entry: A182105.
###How?
This is a two-stage recursive function.
We first build the sequence \$(u_n,v_n)\$ defined as \$(u_1,v_1)=(1,1)\$ and:
$$(u_{n+1},v_{n+1})=\begin{cases}(u_{n}+1,1),&\text{if }(u_{n}\text{ AND }-u_{n})=v_{n}\\(u_{n},2v_{n}),&\text{otherwise}\end{cases}$$
During the second pass, we build the list \$[u_n-v_n,u_n-v_n+1,\dots,u_n]\$ and eventually return it.
#JavaScript (ES6), 97 bytes
Returns wrapping uppercase letters.
n=>(s=i='',g=v=>(s+=String.fromCharCode(65+i++%26),n--)?g(u&-u^v?v*2:!!u++):s.substr(u-v,v))(u=1)
Or 91 bytes in lowercase.
- 205.5k
- 21
- 187
- 670