A356840 Largest most common prime factor of n.
2, 3, 2, 5, 3, 7, 2, 3, 5, 11, 2, 13, 7, 5, 2, 17, 3, 19, 2, 7, 11, 23, 2, 5, 13, 3, 2, 29, 5, 31, 2, 11, 17, 7, 3, 37, 19, 13, 2, 41, 7, 43, 2, 3, 23, 47, 2, 7, 5, 17, 2, 53, 3, 11, 2, 19, 29, 59, 2, 61, 31, 3, 2, 13, 11, 67, 2, 23, 7, 71, 2, 73, 37, 5, 2, 11, 13, 79, 2, 3, 41, 83
Offset: 2
Examples
a(180) = 3, since 180 = 2^2 * 3^2 * 5 and the largest of the most common prime factor is 3.
Links
- Jens Ahlström, Table of n, a(n) for n = 2..9999
Programs
-
Mathematica
a[n_] := Module[{f = FactorInteger[n], p, e}, p = f[[;; , 1]]; e = f[[;; , 2]]; p[[Position[e, Max[e]][[-1,1]]]]]; Array[a, 100, 2] (* Amiram Eldar, Sep 01 2022 *)
-
PARI
a(n) = my(f=factor(n), m=vecmax(f[,2]), w=select(x->(f[x,2] == m), [1..#f~])); vecmax(vector(#w, k, f[w[k], 1])); \\ Michel Marcus, Sep 01 2022
-
Python
from sympy import factorint from collections import Counter def reversed_factors(n): return dict(reversed(list(factorint(n).items()))) def a(n): return Counter(reversed_factors(n)).most_common(1)[0][0]
-
Python
from sympy import factorint def A356840(n): return max(factorint(n).items(),key=lambda x:(x[1],x[0]))[0] # Chai Wah Wu, Sep 10 2022
Comments