cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A261891 Least k>0 such that n AND (k*n) = 0, where AND stands for the binary AND operator.

This page as a plain text file.
%I A261891 #22 Jul 19 2024 19:08:45
%S A261891 2,2,4,2,2,4,8,2,2,2,12,4,10,8,16,2,2,2,4,2,2,12,24,4,4,10,12,8,10,16,
%T A261891 32,2,2,2,4,2,2,4,40,2,2,2,12,12,10,24,48,4,4,4,4,10,34,12,56,8,18,10,
%U A261891 12,16,42,32,64,2,2,2,4,2,2,4,8,2,2,2,12,4,10
%N A261891 Least k>0 such that n AND (k*n) = 0, where AND stands for the binary AND operator.
%C A261891 All terms are even.
%C A261891 a(A003714(n)) = 2 for any n>0.
%C A261891 a(A004780(n)) > 2 for any n>0.
%C A261891 a(n) <= 2^A116361(n) for any n>0.
%C A261891 a(2n) = a(n) for any n>0.
%H A261891 Paul Tek, <a href="/A261891/b261891.txt">Table of n, a(n) for n = 1..16384</a>
%e A261891 For n=7:
%e A261891 +---+-------------+
%e A261891 | k | 7 AND (k*7) |
%e A261891 |   | (in binary) |
%e A261891 +---+-------------+
%e A261891 | 1 |         111 |
%e A261891 | 2 |         110 |
%e A261891 | 3 |         101 |
%e A261891 | 4 |         100 |
%e A261891 | 5 |          11 |
%e A261891 | 6 |          10 |
%e A261891 | 7 |           1 |
%e A261891 | 8 |           0 |
%e A261891 +---+-------------+
%e A261891 Hence, a(7) = 8.
%t A261891 Table[k = 1; While[BitAnd[k n, n] != 0, k++]; k, {n, 60}] (* _Michael De Vlieger_, Sep 06 2015 *)
%o A261891 (Perl) sub a {
%o A261891    my $n = shift;
%o A261891    my $k = 1;
%o A261891    while ($n & ($k*$n)) {
%o A261891       $k++;
%o A261891    }
%o A261891    return $k;
%o A261891 }
%o A261891 (PARI) a(n) = {k=1; while (bitand(n, k*n), k++); k;} \\ _Michel Marcus_, Sep 06 2015
%o A261891 (Python)
%o A261891 from itertools import count
%o A261891 def A261891(n): return next(k for k in count(2) if not n&k*n) # _Chai Wah Wu_, Jul 19 2024
%Y A261891 Cf. A003714, A004780, A116361, A261892.
%K A261891 nonn,base,look
%O A261891 1,1
%A A261891 _Paul Tek_, Sep 05 2015