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.

A356840 Largest most common prime factor of n.

Original entry on oeis.org

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

Views

Author

Jens Ahlström, Aug 31 2022

Keywords

Comments

Pick the prime factors of n with the largest exponent. a(n) is the largest one of those prime factors. If the prime factorization of n has a unique largest exponent, then a(n) = A356838(n). Otherwise, a(n) is the largest of those most common prime factors, while A356838(n) is the smallest of them.

Examples

			a(180) = 3, since 180 = 2^2 * 3^2 * 5 and the largest of the most common prime factor is 3.
		

Crossrefs

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