%I #19 Sep 23 2024 13:35:39
%S 0,1,2,4,8,9,16,25,32,36,49,64,81,100,121,128,144,169,196,225,256,289,
%T 324,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1024,
%U 1089,1156,1225,1296,1369,1444,1521,1600,1681,1764,1849,1936,2025,2048,2116,2209,2304,2401,2500,2601,2704,2809,2916
%N Union of squares and powers of 2.
%C Union of A000290 and A000079;
%C A188916 and A188917 give positions where squares and powers of 2 occur:
%C n^2: a(A188916(n)) = A000290(n);
%C 2^n: a(A188917(n)) = A000079(n);
%C 4^n: a(A006127(n)) = A000302(n), A006127 is the intersection of A188916 and A188917.
%C A010052(a(n)) + A209229(a(n)) > 0. - _Reinhard Zumkeller_, May 19 2015
%H Reinhard Zumkeller, <a href="/A188915/b188915.txt">Table of n, a(n) for n = 0..10000</a>
%o (Haskell)
%o import Data.List.Ordered (union)
%o a188915 n = a188915_list !! n
%o a188915_list = union a000290_list a000079_list
%o -- _Reinhard Zumkeller_, May 19 2015, Apr 14 2011
%o (Python)
%o from math import isqrt
%o def A188915(n):
%o def bisection(f,kmin=0,kmax=1):
%o while f(kmax) > kmax: kmax <<= 1
%o while kmax-kmin > 1:
%o kmid = kmax+kmin>>1
%o if f(kmid) <= kmid:
%o kmax = kmid
%o else:
%o kmin = kmid
%o return kmax
%o def f(x): return n+x-isqrt(x)-((m:=x.bit_length()-1)>>1)-(m&1)
%o return bisection(f,n-1,n**2) # _Chai Wah Wu_, Sep 19 2024
%Y Cf. A000290, A000079, A010052, A209229, A006127, A188916, A188917.
%K nonn
%O 0,3
%A _Reinhard Zumkeller_, Apr 14 2011