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.

A363612 Number of iterations of phi(x) at n needed to reach a square.

This page as a plain text file.
%I A363612 #21 Jun 15 2023 10:49:36
%S A363612 0,1,2,0,1,2,3,1,0,1,2,1,2,3,2,0,1,3,4,2,2,2,3,2,0,2,4,2,3,2,3,1,3,1,
%T A363612 3,0,1,4,3,1,2,2,3,3,3,3,4,1,0,3,2,3,4,4,2,3,1,3,4,1,2,3,1,0,2,3,4,2,
%U A363612 4,3,4,3,4,1,2,1,2,3,4,2,0,2,3,3,1,3,4
%N A363612 Number of iterations of phi(x) at n needed to reach a square.
%p A363612 a:= proc(n) option remember;
%p A363612      `if`(issqr(n), 0, 1+a(numtheory[phi](n)))
%p A363612     end:
%p A363612 seq(a(n), n=1..105);  # _Alois P. Heinz_, Jun 12 2023
%t A363612 a[n_] := -1 + Length @ NestWhileList[EulerPhi, n, ! IntegerQ[Sqrt[#]] &]; Array[a, 100] (* _Amiram Eldar_, Jun 11 2023 *)
%o A363612 (Python)
%o A363612 from sympy import totient
%o A363612 from sympy.ntheory.primetest import is_square
%o A363612 def a(n):
%o A363612   x = n
%o A363612   c = 0
%o A363612   while not is_square(x):
%o A363612     x = totient(x)
%o A363612     c += 1
%o A363612   return c
%o A363612 (PARI) a(n) = my(nb=0); while(!issquare(n), n=eulerphi(n); nb++); nb; \\ _Michel Marcus_, Jun 15 2023
%Y A363612 Cf. A000010 (phi), A003434 (to reach 1).
%K A363612 nonn
%O A363612 1,3
%A A363612 _DarĂ­o Clavijo_, Jun 11 2023