login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A335940 a(n) = n if n is prime, a(n) = 0 if n is a nontrivial power of a prime, and otherwise a(n) = max(|p-q| where p, q are distinct primes dividing n}. 1
1, 2, 3, 0, 5, 1, 7, 0, 0, 3, 11, 1, 13, 5, 2, 0, 17, 1, 19, 3, 4, 9, 23, 1, 0, 11, 0, 5, 29, 3, 31, 0, 8, 15, 2, 1, 37, 17, 10, 3, 41, 5, 43, 9, 2, 21, 47, 1, 0, 3, 14, 11, 53, 1, 6, 5, 16, 27, 59, 3, 61, 29, 4, 0, 8, 9, 67, 15, 20, 5, 71, 1, 73, 35, 2, 17, 4, 11, 79, 3, 0, 39, 83 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

LINKS

Table of n, a(n) for n=1..83.

FORMULA

a(n) = A006530(n)-A020639(n) for n composite. - Chai Wah Wu, Jul 01 2020

EXAMPLE

a(12) = 1 because its prime factors (2x2x3) have a maximum difference of 1 (3-2).

a(14) = 5 because its prime factors (2x7) have a maximum difference of 5 (7-2).

PROG

(Python)

import numpy as np

def primeFactors(n):

    x=[]

    while n % 2 == 0:

        x.append(2),

        n = n / 2

    for i in range(3, int(np.sqrt(n))+1, 2):

        while n % i== 0:

            x.append(i),

            n = n / i

    if n > 2:

        x.append(n)

    if len(x)==0:

        x.append(1)

    if len(x)!=1:

        y=x[-1]-x[0]

    else:

        y=x[0]

    return y

    print(len(x))

nums = list(range(1, 101))

final=[]

for i in nums:

    final.append(primeFactors(i))

final = [int(i) for i in final]

print(final)

(Python)

from sympy import primefactors, isprime

def A335940(n):

    if isprime(n):

        return n

    else:

        pf = primefactors(n)

        return max(pf)-min(pf) # Chai Wah Wu, Jul 01 2020

CROSSREFS

Cf. A006530, A020639.

Sequence in context: A066398 A138197 A140664 * A339767 A071321 A071322

Adjacent sequences:  A335937 A335938 A335939 * A335941 A335942 A335943

KEYWORD

nonn

AUTHOR

Elam Blackwell, Jun 30 2020

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 9 21:08 EDT 2022. Contains 356026 sequences. (Running on oeis4.)