login
Nonnegative integers whose trajectory under iteration of taking the absolute value of the alternating sum of the cubes of the digits includes zero.
1

%I #34 Mar 09 2022 10:52:59

%S 0,11,22,33,44,55,58,66,77,85,88,99,110,135,138,142,179,220,232,241,

%T 256,267,284,328,330,345,346,387,396,429,440,464,482,486,531,543,550,

%U 580,587,643,652,660,684,693,762,770,783,785,808,823,831,849,850,868,880,924,948,971,990

%N Nonnegative integers whose trajectory under iteration of taking the absolute value of the alternating sum of the cubes of the digits includes zero.

%C The sequence is infinite. Any number which is formed by concatenating two-digit multiples of 11 is a term.

%C To determine whether a given number k is a term of this sequence, start with k, take the cube of each digit of k, sum them together with alternating signs and take the absolute value of the result, apply the same process to the result, and continue until 0 is reached or a loop is entered. If 0 is reached, k is a term of this sequence. If not, k is not a term of this sequence.

%e 346 is a term of the sequence since: 346->179->387->142->55->0.

%e 8 is not a term since: 8->512->132->18->511->125->118->512 (we reached a loop of length 6 starting with 512).

%t Select[Range[10000],FixedPoint[Abs[Sum[(-1)^(n + 1)*Part[IntegerDigits[#]^3, n], {n, 1,Length[IntegerDigits[#]]}]] &, #, 30] == 0 &]

%o (Python)

%o def happyish_function(number, base: int = 10):

%o total = 0

%o times = 0

%o while number > 0:

%o total += pow(-1, times) * pow(abs(number) % base, 3)

%o number = abs(number) // base

%o times += 1

%o return abs(total)

%o def is_happyish(number: int) -> bool:

%o seen_numbers = set()

%o while number > 0 and number not in seen_numbers:

%o seen_numbers.add(number)

%o number = happyish_function(number)

%o return number == 0

%o print([k for k in range(1000) if is_happyish(k)])

%o (PARI) f(n) = my(d=digits(n)); abs(sum(k=1, #d, (-1)^k*d[k]^3)); \\ A351985

%o already(m, v) = {for (i=1, #v, if (v[i] == m, return (1)););}

%o isok(m) = {my(v=[]); while (m=f(m), if (already(m, v), return(0)); v = concat(v, m);); return(1);} \\ _Michel Marcus_, Feb 27 2022

%Y Cf. A345680, A351985.

%K nonn,base

%O 1,2

%A _Luca Onnis_, Feb 23 2022