OFFSET
1,2
COMMENTS
The sequence is infinite. Any number which is formed by concatenating two-digit multiples of 11 is a term.
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.
EXAMPLE
346 is a term of the sequence since: 346->179->387->142->55->0.
8 is not a term since: 8->512->132->18->511->125->118->512 (we reached a loop of length 6 starting with 512).
MATHEMATICA
Select[Range[10000], FixedPoint[Abs[Sum[(-1)^(n + 1)*Part[IntegerDigits[#]^3, n], {n, 1, Length[IntegerDigits[#]]}]] &, #, 30] == 0 &]
PROG
(Python)
def happyish_function(number, base: int = 10):
total = 0
times = 0
while number > 0:
total += pow(-1, times) * pow(abs(number) % base, 3)
number = abs(number) // base
times += 1
return abs(total)
def is_happyish(number: int) -> bool:
seen_numbers = set()
while number > 0 and number not in seen_numbers:
seen_numbers.add(number)
number = happyish_function(number)
return number == 0
print([k for k in range(1000) if is_happyish(k)])
(PARI) f(n) = my(d=digits(n)); abs(sum(k=1, #d, (-1)^k*d[k]^3)); \\ A351985
already(m, v) = {for (i=1, #v, if (v[i] == m, return (1)); ); }
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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Luca Onnis, Feb 23 2022
STATUS
approved