[go: up one dir, main page]

login
A182539
a(n) = a(n-1) + (a(n-2) AND n).
0
0, 1, 1, 2, 2, 2, 4, 6, 6, 6, 8, 10, 18, 26, 28, 38, 54, 54, 72, 90, 90, 106, 124, 126, 150, 174, 192, 202, 202, 210, 220, 238, 238, 270, 304, 306, 338, 370, 372, 406, 438, 438, 472, 506, 514, 554, 556, 598, 630, 646, 696, 698, 746, 794, 828, 846, 902, 910, 912, 922, 938, 962, 1004, 1006, 1070
OFFSET
0,4
FORMULA
a(0)=0, a(1)=1, a(n) = a(n-1) + (a(n-2) AND n), where AND is the bitwise AND operator.
MATHEMATICA
RecurrenceTable[{a[0]==0, a[1]==1, a[n]==a[n-1]+BitAnd[a[n-2], n]}, a, {n, 70}] (* Harvey P. Dale, Jan 23 2013 *)
PROG
(Python)
prpr, prev = 0, 1
for n in range(2, 99):
. current = prev + (prpr & n)
. print prpr,
. prpr, prev = prev, current
CROSSREFS
Cf. A182537.
Sequence in context: A361404 A248781 A236840 * A170887 A103265 A341695
KEYWORD
nonn,base,easy
AUTHOR
Alex Ratushnyak, May 04 2012
STATUS
approved