OFFSET
1,1
COMMENTS
LINKS
Paul Tek, Table of n, a(n) for n = 1..16384
EXAMPLE
For n=7:
+---+-------------+
| k | 7 AND (k*7) |
| | (in binary) |
+---+-------------+
| 1 | 111 |
| 2 | 110 |
| 3 | 101 |
| 4 | 100 |
| 5 | 11 |
| 6 | 10 |
| 7 | 1 |
| 8 | 0 |
+---+-------------+
Hence, a(7) = 8.
MATHEMATICA
Table[k = 1; While[BitAnd[k n, n] != 0, k++]; k, {n, 60}] (* Michael De Vlieger, Sep 06 2015 *)
PROG
(Perl) sub a {
my $n = shift;
my $k = 1;
while ($n & ($k*$n)) {
$k++;
}
return $k;
}
(PARI) a(n) = {k=1; while (bitand(n, k*n), k++); k; } \\ Michel Marcus, Sep 06 2015
(Python)
from itertools import count
def A261891(n): return next(k for k in count(2) if not n&k*n) # Chai Wah Wu, Jul 19 2024
CROSSREFS
KEYWORD
AUTHOR
Paul Tek, Sep 05 2015
STATUS
approved