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.

A381329 Number of steps for n to reach 1 under the map x -> x/2 if x is even, x -> 2*x+1 if x is prime or a perfect power, otherwise x -> gpf(x)-1 where gpf(x) = A006530(x).

Original entry on oeis.org

0, 1, 5, 2, 16, 6, 4, 3, 10, 17, 15, 7, 20, 5, 3, 4, 8, 11, 9, 18, 7, 16, 14, 8, 6, 21, 19, 6, 7, 4, 8, 5, 18, 9, 7, 12, 4, 10, 8, 19, 23, 8, 8, 17, 3, 15, 13, 9, 19, 7, 5, 22, 11, 20, 18, 7, 12, 8, 6, 5, 21, 9, 7, 6, 8, 19, 4, 10, 17, 8, 9, 13, 8, 5, 3, 11, 18
Offset: 1

Views

Author

Bill McEachen, Feb 20 2025

Keywords

Comments

Does every n reach 1?

Examples

			n=7 reaches 1 by 7 -> 15 -> 4 -> 2 -> 1 which is a(7)=4 steps.
Starting from 47993 yields 4362, 2181, 726, 363, 10, 5, 11, 23, 47, 95, 18, 9, 19, 39, 12, 6, 3, 7, 15, 4, 2, 1. Thus a(47993)=22.
		

Crossrefs

Cf. A006530.

Programs

  • Mathematica
    s[n_] := Which[n == 1, 1, EvenQ[n], n/2, PrimeQ[n] || GCD @@ ((f = FactorInteger[n])[[;; , 2]]) > 1, 2*n + 1, True, f[[-1, 1]] - 1]; a[n_] := -1 + Length@ NestWhileList[s, n, # > 1 &]; Array[a, 100] (* Amiram Eldar, Feb 20 2025 *)