login
Difference between 2^n and largest square strictly less than 2^n.
3

%I #21 Oct 12 2022 05:21:21

%S 1,1,3,4,7,7,15,7,31,28,63,23,127,92,255,7,511,28,1023,112,2047,448,

%T 4095,1792,8191,7168,16383,5503,32767,22012,65535,88048,131071,166831,

%U 262143,296599,524287,444943,1048575,296863,2097151,1187452,4194303

%N Difference between 2^n and largest square strictly less than 2^n.

%C Note that this is not a strictly ascending sequence. - _Alonso del Arte_, Apr 28 2022

%F a(n) = 2^n - (ceiling(2^(n/2)) - 1)^2 = A000079(n) - (A017912(n) - 1)^2. - _Vladeta Jovovic_, May 01 2003

%F a(n) = A071797(A000079(n)). - _Michel Marcus_, Apr 29 2022

%F a(n) = 2^n - A357754(n). - _Kevin Ryde_, Oct 12 2022

%e a(5) = 2^5 - 5^2 = 7;

%e a(6) = 2^6 - 7^2 = 15.

%t Table[2^n - Floor[Sqrt[2^n - Boole[EvenQ[n]]]]^2, {n, 0, 47}] (* _Alonso del Arte_, Apr 28 2022 *)

%o (Python)

%o from math import isqrt

%o def a(n): return 2**n - isqrt(2**n-1)**2

%o print([a(n) for n in range(43)]) # _Michael S. Branicky_, Apr 29 2022

%o (PARI) a(n) = if(n%2, sqrtint(1<<n,&n);n, bitneg(0,n/2+1)); \\ _Kevin Ryde_, Oct 12 2022

%Y Cf. A000079, A017912, A071797, A357754.

%Y Cf. A051213, A056008.

%K nonn,easy

%O 0,3

%A _Henry Bottomley_, Jul 24 2000