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.

A378423 a(n) is the number of distinct terms reached by iterating the function f(x) = 2 + A008472(x), starting from x=n.

Original entry on oeis.org

3, 2, 4, 1, 3, 4, 3, 2, 3, 4, 7, 4, 6, 8, 5, 2, 7, 4, 6, 4, 5, 6, 5, 4, 4, 8, 4, 8, 5, 5, 4, 2, 3, 6, 9, 4, 6, 6, 5, 4, 7, 9, 6, 6, 5, 5, 5, 4, 4, 4, 7, 8, 6, 4, 5, 8, 5, 4, 7, 5, 6, 10, 5, 2, 5, 5, 10, 6, 9, 3, 7, 4, 6, 8, 5, 6, 5, 5, 5, 4, 4, 6, 6, 9, 5, 6, 7, 6, 8, 5, 7, 5, 5, 8, 9, 4, 4, 8, 3, 4
Offset: 1

Views

Author

Rafik Khalfi, Nov 25 2024

Keywords

Comments

a(n)= The number of distinct elements in the set A(n)={f^{k}(n);k>=0}, where f^{k} is the k-th iteration of f.
The set A(n) contains either the fixed point 4 or a cyclic component {5,7,9}.

Examples

			For n=33, 33->16->4->4-> ... and 4 is a fixed point, then a(n)= number of distinct terms = 3.
For n=66, 66->18->7->9->5->7 ... and {5,7,9} is a cyclic component, then a(n)= number of distinct terms = 5.
		

Crossrefs

Cf. A008472.

Programs

  • Maple
    f:= proc(n)
    add( d, d= numtheory[factorset](n)):
    end proc: f(1) := 0:
    g:= proc(n)
       2 + f(n)
    end proc:
     a:= proc(n)
     local k, result:
     k := 1:
    result := n:
    while not (result = 4 or result = 5 or result = 7 or result = 9) do
    result := g(result):
    k := k + 1:
    end do:
    if result = 5 or result = 7 or result = 9 then
    return k + 2;
    else
    return k:
    end if
    end proc:
    map(a, [$1..100]);
  • Mathematica
    a[n_] := -1 + Length@ NestWhileList[2 + If[# == 1, 0, Total[FactorInteger[#][[;; , 1]]]] &, n, UnsameQ, All]; Array[a, 100] (* Amiram Eldar, Nov 26 2024 *)
  • Python
    from sympy import factorint
    def a(n):
        reach = set()
        while n not in reach:
            reach.add(n)
            n = 2 + sum(factorint(n))
        return len(reach)
    print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Nov 26 2024