login
a(n) is the number of iterations of the map x -> n mod sopfr(x) starting with n to reach 0 or 1, where sopfr = A001414.
2

%I #16 Feb 01 2021 13:28:13

%S 0,1,1,1,1,1,1,2,2,2,1,3,1,4,2,1,1,2,1,2,1,4,1,3,2,4,1,3,1,1,1,2,3,3,

%T 3,2,1,4,4,3,1,3,1,4,1,3,1,2,2,2,4,1,1,5,3,2,4,4,1,1,1,4,4,2,4,2,1,4,

%U 2,1,1,1,1,3,3,3,3,3,1,2,3,3,1,1,3,4,5,2,1,3,3,3,3,5,4,2,1,2,2

%N a(n) is the number of iterations of the map x -> n mod sopfr(x) starting with n to reach 0 or 1, where sopfr = A001414.

%C If n is prime, or n is in A164643, then a(n) = 1.

%H Robert Israel, <a href="/A340967/b340967.txt">Table of n, a(n) for n = 1..10000</a>

%e a(12) = 3 because 12 mod (2+2+3) = 5, 12 mod 5 = 2 and 12 mod 2 = 0 (3 iterations).

%e a(54) = 5 because 54 mod (2+3+3+3) = 10, 54 mod (2+5) = 6, 54 mod 5 = 4, 54 mod (2+2) = 2, and 54 mod 2 = 0 (5 iterations).

%p sopfr:= proc(n) local t;

%p add(t[1]*t[2], t = ifactors(n)[2])

%p end proc:

%p f:= proc(n) local x,k;

%p x:= n;

%p for k from 1 do x:= n mod sopfr(x); if x <= 1 then return k fi od;

%p end proc:

%p f(1):= 0:

%p map(f, [$1..200]);

%o (Python)

%o from sympy import factorint

%o def A340967(n):

%o c, x = 0, n

%o while x > 1:

%o c += 1

%o x = n % sum(p*e for p, e in factorint(x).items())

%o return c # _Chai Wah Wu_, Feb 01 2021

%Y Cf. A001414, A164643, A340969.

%K nonn

%O 1,8

%A _J. M. Bergot_ and _Robert Israel_, Jan 31 2021