login
a(n) is the number of entries == 1 mod 4 in row n of Pascal's triangle.
2

%I #30 Jan 05 2025 19:51:40

%S 1,2,2,2,2,4,2,4,2,4,4,4,2,4,4,8,2,4,4,4,4,8,4,8,2,4,4,8,4,8,8,16,2,4,

%T 4,4,4,8,4,8,4,8,8,8,4,8,8,16,2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32,2,

%U 4,4,4,4,8,4,8,4,8,8,8,4,8,8,16,4,8,8

%N a(n) is the number of entries == 1 mod 4 in row n of Pascal's triangle.

%C All entries are powers of 2.

%H Robert Israel, <a href="/A270438/b270438.txt">Table of n, a(n) for n = 0..10000</a>

%H Kenneth S. Davis and William A. Webb, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/29-1/davis.pdf">Pascal's triangle modulo 4</a>, Fib. Quart., 29 (1991), 79-83.

%H A. Granville, <a href="http://www.jstor.org/stable/2324898">Zaphod Beeblebrox's Brain and the Fifty-ninth Row of Pascal's Triangle</a>, The American Mathematical Monthly, 99(4) (1992), 318-331.

%F a(n) = 2^(A000120(n) - min(1, A014081(n))). [Davis & Webb]

%e Row 3 of Pascal's triangle is (1,3,3,1) and has two entries == 1 (mod 4), so a(3) = 2.

%p f:= proc(n) local L,m;

%p L:= convert(n,base,2);

%p m:= convert(L,`+`);

%p if has(L[1..-2]+L[2..-1],2) then 2^(m-1) else 2^m fi

%p end proc:

%p map(f, [$0..1000]);

%t Count[#, 1] & /@ Table[Mod[Binomial[n, k], 4], {n, 0, 120}, {k, 0, n}] (* _Michael De Vlieger_, Feb 26 2017 *)

%o (PARI) a(n) = 2^(hammingweight(n) - min(hammingweight(bitand(n, n>>1)),1)) \\ _Charles R Greathouse IV_, Jul 13 2016

%Y Cf. A034931, A163000, A000120, A007318, A014081.

%K nonn,easy

%O 0,2

%A _Robert Israel_, Jul 12 2016