OFFSET
1,6
COMMENTS
Integers k and m such that gcd(k,m) = 2^t, t > 0, are called 2-Friendly in Project Euler (see link).
If k=m were included then the number of pairs would A049690(floor(n/2)), and subtracting those cases is the 2nd formula.
If gcd(k,m) = 2^t, t > 0 is replaced by gcd(k,m) = 2*t, t > 0, with 1 <= k < m <= n+4, sequence becomes A008805.
LINKS
Project Euler, Problem 643: 2-Friendly.
EXAMPLE
a(6)=3 because gcd(2,4)=2, gcd(2,6)=2, gcd(4,6)=2.
12 and 18 are not 2-friendly because gcd(12,18) = 6.
MATHEMATICA
q[n_] := n > 1 && n == 2^IntegerExponent[n, 2]; a[n_] := Module[{c = 0}, Do[Do[If[q[GCD[k, m]], c++], {k, 2, m - 1}], {m, 2, n}]; c]; Array[a, 60] (* Amiram Eldar, Nov 23 2022 *)
PROG
(PARI) a(n) = { my(res = 0); forvec(x = vector(2, i, [1, floor(n/2)]), c = gcd(x[1], x[2]); if(c == 1 << logint(c, 2), res++ ) , 2 ); res } \\ David A. Corneth, Nov 24 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Bernard Schott, Nov 23 2022
STATUS
approved