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.

A178313 Absolute difference between prime factors of n-th semiprime mod n.

Original entry on oeis.org

0, 1, 0, 3, 0, 2, 4, 1, 0, 1, 8, 3, 2, 3, 10, 5, 0, 14, 6, 16, 6, 7, 8, 20, 10, 4, 12, 12, 12, 26, 6, 28, 12, 14, 16, 34, 18, 19, 10, 0, 18, 38, 40, 12, 20, 44, 22, 2, 24, 21, 26, 25, 50, 16, 26, 0, 56, 29, 58, 32, 6, 33, 1, 35, 22, 36, 34, 8, 68, 35, 38, 24, 34, 70, 4, 35, 42, 76, 6, 0
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Dec 20 2010

Keywords

Examples

			a(2)=1 because semiprime(2) = 6 = 3*2 and (3-2) mod 2 = 1.
		

Crossrefs

Programs

  • Mathematica
    semiPrimeQ[n_] := Plus @@ Last /@ FactorInteger@ n == 2; f[n_] := Subtract @@ Reverse@ Flatten[ Table[ #[[1]], {#[[2]]}] & /@ FactorInteger@ n]; t = Select[ Range@ 215, semiPrimeQ]; Table[ Mod[ f[ t[[n]]], n], {n, 80}]
    f[{a_,b_}]:=Module[{c=FactorInteger[b][[;;,1]]},If[Length[c]==1,0,Mod[Differences[c][[1]],a]]]; Module[{nn=300,spr},spr=Select[Range[nn],PrimeOmega[#]==2&];f/@Thread[{Range[ Length[ spr]],spr}]] (* Harvey P. Dale, May 29 2024 *)
  • Python
    from math import isqrt
    from sympy import primepi, primerange, primefactors
    from sympy.ntheory.primetest import is_square
    def A178313(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return int(n+x+((t:=primepi(s:=isqrt(x)))*(t-1)>>1)-sum(primepi(x//p) for p in primerange(s+1)))
        return 0 if is_square(m:=bisection(f,n,n)) else ((p:=primefactors(m))[1]-p[0])%n # Chai Wah Wu, Apr 03 2025