login
A165818
Largest integer coprime to n whose binary representation is a substring of the binary representation of n.
0
1, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 3, 7, 1, 8, 1, 9, 1, 10, 5, 11, 1, 12, 5, 13, 3, 14, 7, 15, 1, 16, 1, 17, 1, 18, 9, 19, 1, 20, 5, 21, 5, 22, 11, 23, 1, 24, 9, 25, 5, 26, 13, 27, 3, 28, 13, 29, 7, 30, 15, 31, 1, 32, 1, 33, 1, 34, 17, 35, 1, 36, 9, 37, 9, 38, 19, 39, 1, 40, 9, 41, 5, 42, 21
OFFSET
1,5
EXAMPLE
14 in binary is 1110. The integers that, when written in binary, occur as substrings in 1110 are 0, 1, 2 (10 in binary), 3 (11 in binary), 6 (110 in binary), 7 (111 in binary), and 14 (1110 in binary). Of these, 3 is the largest that is coprime to 14. So a(14) = 3.
PROG
(PARI) { a(n) = my(m, b, s); m=0; b=binary(n); for(i=1, #b, for(j=i, #b, s=sum(k=i, j, b[k]*2^(j-k)); if(gcd(s, n)==1&&m<s, m=s) )); m } /* Max Alekseyev, Oct 01 2009 */
CROSSREFS
Sequence in context: A090331 A338759 A229994 * A369895 A194746 A198336
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Sep 28 2009
EXTENSIONS
More terms from Max Alekseyev, Oct 01 2009
STATUS
approved