OFFSET
1,2
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
EXAMPLE
1 is the seed value of the sequence. 2 is in the sequence because 2 = 1^2 + 1 and 1 is in the sequence. 3 is in the sequence because 3 = 2^2 - 1 and 2 is in the sequence.
PROG
(Python)
def func(i):
.a=[2]
.pows={2:2}
.for rep in range(i):
..for x in a[:]:
...if not x**pows[x]-1 in a:
....a.append(x**pows[x]-1)
....pows[x**pows[x]-1]=2
...if not x**pows[x]+1 in a:
....a.append(x**pows[x]+1)
....pows[x**pows[x]+1]=2
...pows[x]+=1
..a.sort()
.return a
(PARI) is(n)=if(n<4, 1, my(t); (ispower(n-1, , &t)&&is(t)) || (ispower(n+1, , &t)&&is(t))) \\ Charles R Greathouse IV, Aug 08 2013
(PARI) list(lim)=my(v=List([1, 2]), i=1); while(i++<=#v, for(e=2, log(lim+2)\log(v[i]), listput(v, v[i]^e-1); listput(v, v[i]^e+1))); vecsort(Vec(v), , 8) \\ Charles R Greathouse IV, Aug 08 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Alexander E. Koren, Jul 31 2013
STATUS
approved