OFFSET
0,3
LINKS
Peter Kagey, Table of n, a(n) for n = 0..10000
EXAMPLE
a(2) = lcm(2) = 2 because 2*2 = 2^2;
a(3) = lcm(1, 2) = 2 because 2*3 = 2^1 + 2^2;
a(7) = lcm(1, 2, 3) = 6 because 2*7 = 2^3 + 2^2 + 2^1.
MATHEMATICA
lcm[n_]:=Module[{idn2=IntegerDigits[n, 2]}, LCM@@Pick[Reverse[Range[ Length[ idn2]]], idn2, 1]]; Join[{1}, Array[lcm, 100]] (* Harvey P. Dale, Jan 24 2019 *)
PROG
(PARI) a(n) = my(ve = select(x->x==1, Vecrev(binary(2*n)), 1)); lcm(vector(#ve, k, ve[k]-1)); \\ Michel Marcus, Apr 12 2016
(PARI) a(n)=lcm(Vec(select(x->x, Vecrev(binary(n)), 1))) \\ Charles R Greathouse IV, Apr 12 2016
(Python)
from math import lcm
def A271410(n): return lcm(*(i for i, b in enumerate(bin(n)[:1:-1], 1) if b == '1')) # Chai Wah Wu, Dec 12 2022
CROSSREFS
KEYWORD
AUTHOR
Peter Kagey, Apr 11 2016
STATUS
approved