cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A106418 Smallest number beginning with 8 that is the product of exactly n distinct primes.

Original entry on oeis.org

83, 82, 805, 858, 8610, 81510, 870870, 80150070, 800509710, 8254436190, 800680310430, 8222980095330, 800160280950030, 80008785365579070, 843685980760953330, 80058789202898516010, 8003887646839494820410
Offset: 1

Views

Author

Ray Chandler, May 02 2005

Keywords

Examples

			a(3) = 805 = 5*7*23.
		

Crossrefs

Programs

  • Python
    from itertools import count
    from math import prod, isqrt
    from sympy import primerange, integer_nthroot, primepi, primorial
    def A106418(n):
        if n == 1: return 83
        def g(x,a,b,c,m): yield from (((d,) for d in enumerate(primerange(b+1,isqrt(x//c)+1),a+1)) if m==2 else (((a2,b2),)+d for a2,b2 in enumerate(primerange(b+1,integer_nthroot(x//c,m)[0]+1),a+1) for d in g(x,a2,b2,c*b2,m-1)))
        def f(x): return int(sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x,0,1,1,n)))
        def bisection(f,kmin,kmax,mmin,mmax):
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                mmid = f(kmid)
                if mmid > mmin:
                    kmax, mmax = kmid, mmid
                else:
                    kmin, mmin = kmid, mmid
            return kmax
        for l in count(len(str(primorial(n)))-1):
            kmin, kmax = 8*10**l-1, 9*10**l-1
            mmin, mmax = f(kmin), f(kmax)
            if mmax>mmin: return bisection(f,kmin,kmax,mmin,mmax) # Chai Wah Wu, Aug 31 2024