reviewed
approved
reviewed
approved
proposed
reviewed
editing
proposed
(Python) # faster for initial segment of sequence
import heapq
from itertools import islice
def A051037gen(): # generator of terms
v, oldv, h, psmooth_primes, = 1, 0, [1], [2, 3, 5]
while True:
v = heapq.heappop(h)
if v != oldv:
yield v
oldv = v
for p in psmooth_primes:
heapq.heappush(h, v*p)
print(list(islice(A051037gen(), 65))) # Michael S. Branicky, Sep 17 2024
proposed
editing
editing
proposed
i5 for j in range(integer_log(y:= x//5**i, 3)[0]+1):
for j in range(integer_log(x//i5, 3)[0]+1):
c -= (xy//(i5*3**j)).bit_length()
approved
editing
proposed
approved
editing
proposed
return bisection(f, n, n) # Chai Wah Wu, Sep 16 2024
(Python)
from sympy import integer_log
def A051037(n):
def bisection(f, kmin=0, kmax=1):
while f(kmax) > kmax: kmax <<= 1
while kmax-kmin > 1:
kmid = kmax+kmin>>1
if f(kmid) <= kmid:
kmax = kmid
else:
kmin = kmid
return kmax
def f(x):
c = n+x
for i in range(integer_log(x, 5)[0]+1):
i5 = 5**i
for j in range(integer_log(x//i5, 3)[0]+1):
c -= (x//(i5*3**j)).bit_length()
return c
return bisection(f, n, n) # Chai Wah Wu, Sep 16 2024
approved
editing