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.

A106414 Smallest number beginning with 4 that is the product of exactly n distinct primes.

Original entry on oeis.org

41, 46, 42, 462, 4290, 43890, 4001970, 40029990, 406816410, 40026056070, 408036859230, 40013061952710, 405332750552730, 40111962162442170, 4000228915204892370, 40909794684132183810, 4000669166940700163910
Offset: 1

Views

Author

Ray Chandler, May 02 2005

Keywords

Examples

			a(1) = 41, a(3) = 42 = 2*3*7..
		

Crossrefs

Programs

  • Python
    from itertools import count
    from math import prod, isqrt
    from sympy import primerange, integer_nthroot, primepi, primorial
    def A106414(n):
        if n == 1: return 41
        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)))
        for l in count(len(str(primorial(n)))-1):
            kmin, kmax = 4*10**l-1, 5*10**l-1
            mmin, mmax = f(kmin), f(kmax)
            if mmax>mmin:
                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 # Chai Wah Wu, Sep 12 2024