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.
%I A350414 #40 Jan 21 2022 14:35:38 %S A350414 1,2,4,8,16,21,20,18,25,28,34,35,37,41,38,43,42,40,36,39,45,46,48,52, %T A350414 49,54,53,51,47,50,45,46,48,52,49,54,53,51,47,50,45,46,48,52,49,54,53, %U A350414 51,47,50,45,46,48,52,49,54,53,51,47,50,45,46,48,52,49,54,53,51,47,50,45 %N A350414 a(1)=1; for n > 1, a(n) = a(n-1) + (sum of odd-indexed digits of a(n-1)) - (sum of even-indexed digits of a(n-1)). %C A350414 For n > 1, a(n) is obtained from a(n-1) by adding to a(n-1) its odd-indexed digits (ones, hundreds, etc.) and subtracting its even-indexed digits (tens, thousands, etc.). After the first 21 terms, the sequence repeats with period 10. %C A350414 It has been confirmed that if a(1) were changed to any other number <= 10^6, the resulting sequence would similarly enter a loop. If we let x=a(1) and define f(x) as the number of terms before the repeating part begins, then f(x) is symmetric. %H A350414 <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (1,0,0,0,-1,1). %F A350414 From _Chai Wah Wu_, Jan 20 2022: (Start) %F A350414 a(n) = a(n-1) - a(n-5) + a(n-6) for n > 26. %F A350414 G.f.: x*(-11*x^25 - 11*x^20 - 11*x^15 - 11*x^13 - 11*x^10 - 11*x^9 - 11*x^8 - 6*x^5 - 8*x^4 - 4*x^3 - 2*x^2 - x - 1)/(x^6 - x^5 + x - 1). (End) %e A350414 If starting with 12, the next number will be 12 + ((-1)*1 + (1)*2) = 13. %e A350414 Then the next will be 13 + ((-1)*1 + (1)*3) = 15. This will continue as 19, 27, 32, 31, 29, 36, 39, 45, 46, 48, 52, 49, 54, 53, 51, 47, 50, 45. %e A350414 At this point it will loop. %e A350414 When the sequence starts with 1, it will be 1, 2, 4, 8, 16, 21, 20, 18, 25, 28, 34, 35, 37, 41, 38, 43, 42, 40, 36, 39, 45, 46, 48, 52, 49, 54, 53, 51, 47, 50, 45, ... Then this will loop. Hence I showed till 45 If you start with some other case, say a 2 digit number 26. Then, it will be 26, 30, 27, 32, 31, 29, 36, 39, 45, ... Since 45 is part of the previous loop, this will also loop. Picking any 3 digit number, say 155, it will be 155, 156, 158, 162, 159, 164, 163, 161, 157, 160, 155, ... Then it will loop. I tried for numbers up to a million and could see all loop. When plotting, then gave interesting plots with respect to the number of terms they loop after. %t A350414 NestList[#1 + Total[#2[[1 ;; -1 ;; 2]]] - Total[#2[[2 ;; -1 ;; 2]]] & @@ {#, Reverse@ IntegerDigits[#]} &, 1, 67] (* _Michael De Vlieger_, Dec 31 2021 *) %o A350414 (Python) %o A350414 def get_next_num(num): %o A350414 res = [int(x) for x in str(num)[::-1]] %o A350414 sum=0 %o A350414 for i in range(len(res)): %o A350414 if(i%2)==0: %o A350414 sum+=res[i]*1 %o A350414 else: %o A350414 sum+=res[i]*-1 %o A350414 return num+sum %o A350414 termlen=[] %o A350414 for i in range(10000): %o A350414 starting_num=i %o A350414 series=[] %o A350414 current_num=starting_num %o A350414 c=0 %o A350414 while(current_num not in series): %o A350414 series.append(current_num) %o A350414 current_num=get_next_num(current_num) %o A350414 c+=1 %o A350414 if (c>10000000): %o A350414 print(i,"doesn't terminate") %o A350414 break %o A350414 termlen.append(len(series)) %o A350414 import matplotlib.pyplot as plt %o A350414 import numpy as np %o A350414 plt.plot(np.array(termlen)) %o A350414 plt.show() %o A350414 import pandas as pd %o A350414 s = pd.Series(termlen) %o A350414 s.describe() %K A350414 nonn,base %O A350414 1,2 %A A350414 _Divyanand Valsan_, Dec 30 2021