OFFSET
1,5
COMMENTS
This sequence has similarities with A038374: here we consider the binary expansion of 1/n, there the binary expansion of n.
FORMULA
EXAMPLE
The first terms, alongside the binary representation of 1/n, are:
n a(n) bin(1/n) with repeating digits in parentheses
-- ---- ---------------------------------------------
1 1 1.(0)
2 1 0.1(0)
3 1 0.(01)
4 1 0.01(0)
5 2 0.(0011)
6 1 0.0(01)
7 1 0.(001)
8 1 0.001(0)
9 3 0.(000111)
10 2 0.0(0011)
11 3 0.(0001011101)
12 1 0.00(01)
13 3 0.(000100111011)
14 1 0.0(001)
15 1 0.(0001)
16 1 0.0001(0)
17 4 0.(00001111)
18 3 0.0(000111)
19 4 0.(000011010111100101)
20 2 0.00(0011)
PROG
(PARI) a(n) = my (w=1, s=Set(), f=1/max(n, 2)); while (!setsearch(s, f), while (floor(f*2^(w+1))==2^(w+1)-1, w++); s=setunion(s, Set(f)); f=frac(f*2)); return (w)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 10 2018
STATUS
approved