login
A331961
a(n) is the greatest square number k such that n AND k = k (where AND denotes the bitwise AND operator).
1
0, 1, 0, 1, 4, 4, 4, 4, 0, 9, 0, 9, 4, 9, 4, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 25, 16, 25, 16, 25, 16, 25, 0, 1, 0, 1, 36, 36, 36, 36, 0, 9, 0, 9, 36, 36, 36, 36, 16, 49, 16, 49, 36, 49, 36, 49, 16, 49, 16, 49, 36, 49, 36, 49, 64, 64, 64, 64, 64, 64, 64
OFFSET
0,5
LINKS
FORMULA
a(n) = 0 iff n belongs to A062880.
a(n^2) = n^2.
EXAMPLE
The first terms, alongside the binary representations of n and of a(n), are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 0 10 0
3 1 11 1
4 4 100 100
5 4 101 100
6 4 110 100
7 4 111 100
8 0 1000 0
9 9 1001 1001
10 0 1010 0
11 9 1011 1001
12 4 1100 100
13 9 1101 1001
14 4 1110 100
15 9 1111 1001
16 16 10000 10000
PROG
(PARI) a(n) = forstep (m=sqrtint(n), 0, -1, if (bitand(n, m^2)==m^2, return (m^2)))
(Python)
from math import isqrt
def A331961(n): return next(m for m in (k**2 for k in range(isqrt(n), -1, -1)) if n&m==m) # Chai Wah Wu, Aug 22 2023
CROSSREFS
Sequence in context: A214926 A268368 A274947 * A279406 A171408 A071907
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Feb 02 2020
STATUS
approved