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.

User: Gabriel Antonius

Gabriel Antonius's wiki page.

Gabriel Antonius has authored 1 sequences.

A323785 Iteratively swap prime factors of n with their exponent (unless the exponent is 1), until a cycle is reached, and then record the largest term in the cycle.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 16, 19, 20, 21, 22, 23, 27, 32, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 32, 37, 38, 39, 45, 41, 42, 43, 44, 45, 46, 47, 48, 128, 32, 51, 52, 53, 54, 55, 63, 57, 58, 59, 60, 61, 62, 63, 32, 65, 66, 67
Offset: 1

Author

Gabriel Antonius, Aug 31 2019

Keywords

Examples

			For n=196, the iterative procedure evolves as follows: 196 = 2^2 * 7^2 --> 2^2 * 2^7 = 2^9 --> 9^2 = 3^4 --> 4^3 = 2^6 --> 6^2 = 3^2 * 2^2 --> 2^3 * 2^2 = 2^5 --> 5^2 --> 2^5 = 32.
Since the iterative procedure stabilizes in the cycle 2^5=32 <--> 5^2=25, of length 2, the largest ,member of which is 32, we get a(196)=32.
		

Crossrefs

Cf. A008477.

Programs

  • Mathematica
    p[x_, y_] := If[y > 1, y^x, x^y]; f[n_] := Times @@ (p[First[#], Last[#]] & /@ FactorInteger[n]); a[n_] := Module[{k = n, s = {k}}, While[! MemberQ[s, (k = f[k])], AppendTo[s, k]]; ind = Position[s, ?(# == k &)][[1, 1]]; Max[s[[ind ;; -1]]]]; Array[a, 57] (* _Amiram Eldar, Sep 02 2019 *)
  • Python
    def a(n):
        np = swap_prime_factors_with_exponents(n)
        npp = swap_prime_factors_with_exponents(np)
        return max(n, np) if n == npp else a(npp)
    def swap_prime_factors_with_exponents(n):
        np = 1
        for p in primes:
            q = 0
            while n % p == 0:
                q += 1
                n = n // p
            if q > 1: np *= q ** p
            if q == 1: np *= p
        if n > 1: np *= n
        return np
    N = 200
    primes = []
    for n in range(2, int(N ** (1/2)) + 1):
        if all(n % p > 0 for p in primes):
            primes.append(n)
    for n in range(1,N+1):
        print(n, a(n))