OFFSET
1,2
COMMENTS
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..65537 (terms 1..10000 from Reinhard Zumkeller)
FORMULA
For n > 1, a(n) = A003602(n-1) + 1. - Benoit Cloitre, May 26 2007, indexing corrected by Antti Karttunen, Feb 05 2020
a((2*n-3)*2^p+1) = n, p >= 0 and n >= 2, with a(1) = 1. - Johannes W. Meijer, Jan 28 2013
Sum_{k=1..n} a(k) ~ n^2/6. - Amiram Eldar, Sep 24 2023
MAPLE
nmax := 82: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 2 to ceil(nmax/(p+2))+1 do a((2*n-3)*2^p+1) := n od: od: a(1) := 1: seq(a(n), n=1..nmax); # Johannes W. Meijer, Jan 28 2013
MATHEMATICA
a[n_] := ((n-1)/2^IntegerExponent[n-1, 2] + 3)/2; a[1] = 1; Array[a, 100] (* Amiram Eldar, Sep 24 2023 *)
PROG
(Haskell)
-- import Data.List (transpose)
a103391 n = a103391_list !! (n-1)
a103391_list = 1 : ks where
ks = concat $ transpose [[2..], ks]
-- Reinhard Zumkeller, May 23 2013
(PARI)
(Python)
def v(n): b = bin(n); return len(b) - len(b.rstrip("0"))
def b(n): return (n//2**v(n)+1)//2
def a(n): return 1 if n == 1 else 1 + b(n-1)
print([a(n) for n in range(1, 106)]) # Michael S. Branicky, May 29 2022
(Python)
def A103391(n): return (n-1>>(n-1&-n+1).bit_length())+2 if n>1 else 1 # Chai Wah Wu, Jan 04 2024
CROSSREFS
Differs from A351460.
KEYWORD
easy,nonn
AUTHOR
Eric Rowland, Mar 20 2005
EXTENSIONS
Data section extended up to a(105) (to better differentiate from several nearby sequences) by Antti Karttunen, Feb 05 2020
STATUS
approved