OFFSET
0,5
COMMENTS
Although this is a list, we set the offset to 0 for more intuitive usage: a(n) is the index of the class to which the integer n belongs. There are six mutually exclusive classes, and the nonnegative integers are the union of these classes.
The six classes are defined as follows: n is in class C0 <=> n in {0, 1}. For n >= 2, let F(n) represent the canonical prime factorization of n, p the sequence of prime factors in F(n), and e the corresponding sequence of exponents. Define three Boolean expressions: L = [card(p) = 1], M = [max(e) = 1], and E = [card(set(e)) = 1], where [.] denotes the Iverson bracket. Then n is in C1 <=> L and E and M; n is in C2 <=> L and E and not M; n is in C3 <=> not L and not E and not M; n is in C4 <=> not L and E and M; n is in C5 <=> not L and E and not M. This amounts to the mapping: C0 -> {0, 1}, C1 -> A000040, C2 -> A246547, C3 -> A059404, C4 -> A120944, C5 -> A303606. Finally a(n) = k <=> n in Ck; k = 0..5.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Peter Luschny, Python implementation.
EXAMPLE
MATHEMATICA
Table[Which[n < 2, 0, PrimeQ[n], 1, PrimePowerQ[n], 2, SquareFreeQ[n], 4, Length[Union@ FactorInteger[n][[;; , -1]]] == 1, 5, True, 3], {n, 0, 86}] (* Michael De Vlieger, Sep 17 2025 *)
PROG
(Python) # Cf. links.
(SageMath)
def a(n: int) -> int:
if n < 2: return 0
factors = list(factor(n))
exponents = [f[1] for f in factors]
L = 1 == len(factors)
E = 1 == len(set(exponents))
M = 1 == max(exponents)
if L and E: return 1 if M else 2
if E: return 4 if M else 5
return 3
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Peter Luschny, Sep 16 2025
STATUS
approved
